How to preven entering of a naked IP to open a site?
-
- Posts: 36
- Joined: Thu Dec 05, 2013 10:55 am
Re: How to preven entering of a naked IP to open a site?
1. I believe you can not do that. People can visit your site using IP address or domain. CMIIWGreenUnicorn wrote:How to make it only a domain to load a site and naked IP to not load anything at all?
Also when there are lots of sites on a VPS how it decides which one to load?
I believe before it wasn't loading any particular site but the default one, but now seems to always load one of the sites.
2. If your domain has been added to the vestacp configuration it will be loaded automatically, if not, then the default page will be served to the visitor.
Actually I don't really get into your question, but hopefully my answer works for you.
Re: How to preven entering of a naked IP to open a site?
<?php
if(preg_match("#^[0-9\.$]+#",$_SERVER['REMOTE_ADDR']){
die();
/*
Or
header('location:http://www.url.com');
*/
}
?>
You can achive this with php, and "default domain'
another approach is via .htaccess
http://stackoverflow.com/questions/1055 ... www-domain
Options +FollowSymlinks
RewriteEngine On
RewriteCond %{HTTP_HOST} ^111\.111\.111\.111 [OR]
RewriteCond %{HTTP_HOST} ^222\.222\.222\.222
RewriteRule (.*) http://www.example.me/$1 [R=301]
if(preg_match("#^[0-9\.$]+#",$_SERVER['REMOTE_ADDR']){
die();
/*
Or
header('location:http://www.url.com');
*/
}
?>
You can achive this with php, and "default domain'
another approach is via .htaccess
http://stackoverflow.com/questions/1055 ... www-domain
Options +FollowSymlinks
RewriteEngine On
RewriteCond %{HTTP_HOST} ^111\.111\.111\.111 [OR]
RewriteCond %{HTTP_HOST} ^222\.222\.222\.222
RewriteRule (.*) http://www.example.me/$1 [R=301]
Re: How to preven entering of a naked IP to open a site?
Apache starts to load site configuration from the file /etc/apache2/conf.d/vesta.conf
This file contains commands to include more configuration files.
Since Apache can't determine the web site to load from the url, because the user typed the IP address instead, it loads the first site it finds in the above config files.
This file contains commands to include more configuration files.
Since Apache can't determine the web site to load from the url, because the user typed the IP address instead, it loads the first site it finds in the above config files.
Re: How to preven entering of a naked IP to open a site?
Sure things, and default.domain it's nice thing for those, who typed IP.Felix wrote: Since Apache can't determine the web site to load from the url, because the user typed the IP address instead, it loads the first site it finds in the above config files.