Apache 2 and virtual hosts
I am desperatly trying to get apache to show two different webpages depending on whether the user typed in www.domain.com or foo.domain.com in the browser.
I have tried a bunch of different setups but either I get some error about overlapping virtual hosts or I get the same webpage no matter what url I type into the browser. So, can someone just please tell me how I need to setup apache to do this for me? www.domain.com should show the page inside /var/www/default/ foo.domain.com should show the page inside /var/www/foo/ Simple. But Apache makes it complex. I am going crazy. |
Yeah, I've done this - its not too bad once you know what you're doing. Too tired to answer properly now, but message me or something if you don't get it sorted in the next couple.
|
If I had to guess, you are getting the "overlapping virtual hosts" error because you are putting a name in the virtualhost tag line. To do what you are trying to do (assuming you have DNS pointing both your URLS to the same server), you would have the following in your httpd.conf file:
NameVirtualHost *:80 <VirtualHost *:80> ServerAdmin webmaster@domain.com DocumentRoot /var/www.domain.com/ ServerName www.domain.com ErrorLog logs/www.domain.com-error_log CustomLog logs/www.domain.com-access_log common </VirtualHost> <VirtualHost *:80> ServerAdmin webmaster@foo.domain.com DocumentRoot /var/foo.domain.com/ ServerName foo.domain.com ErrorLog logs/foo.domain.com-error_log CustomLog logs/foo.domain.com-access_log common </VirtualHost> |
All times are GMT -5. The time now is 01:11 AM. |