: Prevent interactions between Apache virtual hosts on the same server I have a VPS running Apache 2.0, with multiple domains and multiple IPs set. In document root /var/www/html/ I have http://serverA.com
I have a VPS running Apache 2.0, with multiple domains and multiple IPs set.
In document root /var/www/html/ I have serverA.com and I created a virtual host on folder /var/www/html/serverB serving serverB.com.
They work great for both, but the problem is I can access serverB files with URL 'http://serverA.com/serverB/' (which I don't want to happen.)
How can I prevent that?
More posts by @Cugini213
1 Comments
Sorted by latest first Latest Oldest Best
You have to pay attention to two directives specially:
ServerName
DocumentRoot
Below is an example of two virtual hosts configured on top of the same IP:
<VirtualHost W.X.Y.Z:80>
ServerName serverA.com
DocumentRoot "/var/www/html/serverA"
# + other stuff like logging directives, etc.
</VirtualHost>
<VirtualHost W.X.Y.Z:80>
ServerName serverB.com
DocumentRoot "/var/www/html/serverB"
# + other stuff like logging directives, etc.
</VirtualHost>
As you can see both ServerName and DocumentRoot directives are specified and are different. With this kind of configuration you are sure that the two different domain names, "ServerA" and "ServerB", as well as the files they are serving, cannot collide.
The above configuration can easily be adapted for domain names with different IPs as long as you specify the ServerName and the DocumentRoot directives. You have to only change the VirtualHost IP.
Terms of Use Create Support ticket Your support tickets Stock Market News! © vmapp.org2024 All Rights reserved.