Jump to content

Recommended Posts

Posted

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! :)

Posted

The following works for me.

 

NameVirtualHost *:80


DocumentRoot "C:\xampp\htdocs"
ServerName localhost



ServerName xibo.mydomain.com
DocumentRoot "C:\xampp\htdocs\xibo"

  • Thanks 1
Posted

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?

Posted

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 :(

Posted

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 :)

Posted

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?

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 account

Sign in

Already have an account? Sign in here.

Sign In Now



×
×
  • Create New...