Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Apache - multiple websites - allow top folder access

I have multiple websites setup on my Apache2 server. The directory structure is as follows:

/var/www/

/var/www/site1.com

/var/www/site2.com

It is setup such that "www.site1.com" has root folder /var/www/site1, "www.site2.com" has root folder /var/www/site2, and http://server_ip_address has root folder /var/www

However, if I type http://server_ip_address/site1.com, it opens site1.com. I don't want this to happen. (That is, individual sites should be accessible only by typing the correct address).

What is the way to configure this. (Also it would be helpful if you could give tips on best practices for directory structures for multiple websites)?

thanks

JP


1 Answers

The VirtualHost directive can be used to set individual DocumentRoots for each site name. Have also a look at this document: http://httpd.apache.org/docs/2.2/vhosts/name-based.html

like image 140
coldfix Avatar answered May 08 '26 15:05

coldfix



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!