0

For example, Centos 6.8, server ip 1.2.3.4, and some domain added inside vhost.conf

NameVirtualHost *:80

<VirtualHost *:80> 
   ServerAdmin email@example_2.com
   ServerName example_2.com
   ServerAlias www.example_2.com
   DocumentRoot /srv/www/example_2.com/public_html/
   ErrorLog /srv/www/example_2.com/logs/error.log 
   CustomLog /srv/www/example_2.com/logs/access.log combined
</VirtualHost>

<VirtualHost *:80> 
   ServerAdmin email@example_1.com
   ServerName example_1.com
   ServerAlias www.example_1.com
   DocumentRoot /srv/www/example_1.com/public_html/
   ErrorLog /srv/www/example_1.com/logs/error.log 
   CustomLog /srv/www/example_1.com/logs/access.log combined
</VirtualHost>

And etc/hosts file

127.0.0.1 localhost.localdomain localhost 
1.2.3.4 example_1.example_1.com example_1
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6

1.2.3.4 now will point to first VirtualHost in vhost.conf (www.example_2.com)

My question is i dont want people to visit my other website via the ip 1.2.3.4, how can i point the 1.2.3.4 to a blank page or other DocumentRoot?

1 Answers1

0

Apache HTTPD will serve the requested vhost or the first defined vhost if nothing else is a better match. In your example this is as straightforward as defining another vhost earlier in your configuration than example_2.com.

user9517
  • 116,228