Page 1 of 1
Re: How to preven entering of a naked IP to open a site?
Posted: Tue Jul 07, 2015 8:47 am
by VestaLover
GreenUnicorn 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.
1. I believe you can not do that. People can visit your site using IP address or domain. CMIIW
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?
Posted: Tue Jul 07, 2015 10:33 am
by OCPZend
<?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]
Re: How to preven entering of a naked IP to open a site?
Posted: Fri Aug 07, 2015 9:46 pm
by Felix
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.
Re: How to preven entering of a naked IP to open a site?
Posted: Wed Aug 12, 2015 7:53 am
by skurudo
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.
Sure things, and default.domain it's nice thing for those, who typed IP.