How to host multiple domains on Xampp apache server?

captivesglobal
captivesglobal used Ask the Experts™
on
I am not very gud @ linux / apache.. could you be more specfic on how to do it..

I tried uncommentiign NameVirtualHost

and adding

<virtualhost *:80>
servername www.domain1.com
server alias www.domain1.com
directory "c:\xampp\htdocs\domain1"
</virtualhost>


<virtualhost *:80>
servername www.domain2.com
server alias www.domain2.com
directory "c:\xampp\htdocs\domain2"
</virtualhost>

both domain 1 and domain 2 are ridgiterd domain and have dns poinitng to myxampp server. but after configuring this all request are being sent to www.domain1.com .. what exactly could be the problem.. Pls help ists kinda urgent task.
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Lee OsborneSenior Infrastructure Engineer

Commented:
Try setting your httd.conf file like this:

<VirtualHost *>
DocumentRoot C:\xampp\htdocs\domain1
ServerName domain1.com www.domain1.com 
</VirtualHost>

<VirtualHost *>
DocumentRoot C:\xampp\htdocs\domain2
ServerName domain2.com www.domain2.com 
</VirtualHost>

Save the file, then restart Apache.

Lee
Lee OsborneSenior Infrastructure Engineer

Commented:
Sorry, should be httpd.conf , typo!

Lee
Actually, all the original poster needs to do is remove the space between Server and Alias.

<virtualhost *:80>
servername www.domain1.com
serveralias domain1.com
directory "c:\xampp\htdocs\domain1"
</virtualhost>


<virtualhost *:80>
servername www.domain2.com
serveralias domain2.com
directory "c:\xampp\htdocs\domain2"
</virtualhost>

The ServerAlias directive is not required if you're just going to specify the same name as the servername.  It's only required if you want one or more additional domains to be served by the same virtualhost.

The ServerName directive should only have ONE value per VirtualHost.  Additional names should be placed under the ServerAlias.



dear friends,

my actual problem is that all the requests regardless of virtual host created or the default site.. is routed to the first domain..

FOUND A SOLUTION : GOOGLE Yeah!!

When we enable NamedVirtualHost the conf file overrides the default directory .. so we have to mention the default directory as the first virtual host directive

<virtualhost *:80>
servername localhost
directory "c:\xampp\htdocs"
</virtualhost>

<virtualhost *:80>
servername www.domain1.com
directory "c:\xampp\htdocs\domain1"
</virtualhost>


This worked for me and everything is fine.. Thanx guys

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial