jimothy Posted October 22, 2010 Posted October 22, 2010 I've seen this topic covered before so please forgive me but I'm having some real problems getting my head round virtual hosts. I understand the theory but can't get it working in practice. Scenerio: 1 W2k3 server with XAMPP installed. 4 websites running from separate folders in htdocs. These all work well and can be browsed from http://servername/website. For a couple of the sites I would like them to use a virtual host. i.e. just hosted xibo so instead of browsing to http://servername/xibo I'd like to use http://xibo.mydomain.com. Setup an A name record in DNS to point http://xibo.mydomain.com to the servers IP. That's all cool. Read up from Apache how to modify the httpd-vhosts.conf file. Added the following and removed the ## from NameVirtualHost *:80 : DocumentRoot C:\Xampp\htdocs DocumentRoot C:\Xampp\htdocs\xibo ServerName xibo.mydomain.com The first host is to ensure anyother traffic gets directed at the root of the htocs folder. This works fine. If I browse to http://xibo.mydomain.com I get the root of the web server... What am I doing wrong guys? Fanks!
Arthur Posted October 23, 2010 Posted October 23, 2010 The following works for me. NameVirtualHost *:80 DocumentRoot "C:\xampp\htdocs" ServerName localhost ServerName xibo.mydomain.com DocumentRoot "C:\xampp\htdocs\xibo" 1
kmount Posted October 23, 2010 Posted October 23, 2010 I suspect the key bit missing is NameVirtualHost as Arthur has laid out above. 1
jimothy Posted October 23, 2010 Author Posted October 23, 2010 Thanks for the replies. I've already uncommented the NameVirtualHost *:80 line and using the example Arthur has given sadly doesn't resolve my problem; in fact it makes it worse as none of the sites are accessible. I can't see what's wrong... Any other ideas?
jimothy Posted October 23, 2010 Author Posted October 23, 2010 This is all I have in my httpd-vhosts.conf file: NameVirtualHost *:80 DocumentRoot C:\Xampp\htdocs\xibo ServerName xibo.concordcollege.org.uk And if I browse to xibo.concordcollege.org.uk I still get the root of the web server... grrr I've tested XAMPP on another system and have exactly the same in the httpd-vhosts.conf file and that works... my head hurts
jimothy Posted October 23, 2010 Author Posted October 23, 2010 Ok, got this sorted out now, working on this on a Saturday night! sad huh? Here's the working httpd-vhosts.conf file: NameVirtualHost *:80 DocumentRoot "C:\xampp\htdocs" ServerName localhost DocumentRoot C:\Xampp\htdocs\xibo ServerName [color="red"]http://[/color]xibo.concordcollege.org.uk That pesky little http:// fixed it! Bizarre huh? Hope this helps someone else in the future. Thanks to Arthur for the tips on sorting this out
Arthur Posted October 23, 2010 Posted October 23, 2010 Glad you got it sorted in the end. That pesky little http:// fixed it! Bizarre huh? Very strange. I added the domain name to my hosts file so maybe that's why it works without the http:// for me?
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now