crp Posted February 13, 2012 Share Posted February 13, 2012 I want my CentOS server to serve up different pages depending on whether the user entered in rh5.ex123.xyz or forum.ex123.xyz rh5 to provide the files in /var/www/html forum to provide the files in /var/www/mybb I put the following into the httpd.conf <VirtualHost *:80> DocumentRoot /var/www/mybb <Directory "/var/www/mybb"> allow from all Options +Indexes </Directory> ServerName forum.ex123.xyz </VirtualHost> Problem is , entering forum.ex123.xyz or rh5.ex123.xyz both serve up the pages of forum. How do I setup the configuration file so that the forum files only get served up if forum.ex123.xyz in the address in the URL ? Quote Link to comment Share on other sites More sharing options...
Peachy Posted February 14, 2012 Share Posted February 14, 2012 You'll need to create two virtual host stanzas. NameVirtualHost *:80 <VirtualHost *:80> DocumentRoot /var/www/html ServerName rh5.ex123.xyz <Directory /var/www/html> allow from all Options +Indexes </Directory> </VirtualHost> <VirtualHost *:80> DocumentRoot /var/www/mybb ServerName forum.ex123.xyz <Directory /var/www/mybb> allow from all Options +Indexes </Directory> </VirtualHost> Make sure the NameVirtualHost directive is uncommented if not already. The other thing to remember is that you will need to make sure you have DNS or host file entries on the client for both site name. Quote Link to comment Share on other sites More sharing options...
crp Posted February 14, 2012 Author Share Posted February 14, 2012 (edited) oh, I thought that there was a default built into Apache so that if the URL name is not used but it's DNS is pointing to the pc's IP address, /var/www/html is used. Edited February 14, 2012 by crp Quote Link to comment Share on other sites More sharing options...
Peachy Posted February 15, 2012 Share Posted February 15, 2012 oh, I thought that there was a default built into Apache so that if the URL name is not used but it's DNS is pointing to the pc's IP address, /var/www/html is used. I thought that too, but I think the behaviour has changed and you must explicitly put the default in a virtualhost directive. It's been a couple of years since I've set that up so if you give me some time I can verify that in my test lab. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.