Page 1 of 1

Adding several domains tosame host with different root vhost

PostPosted: 20. October 2009 11:32
by Znote
Hello, I downloaded xampp so I could host homesites.

I got separate domains, like:
z-note.net
skarheimdata.dyndns.org
flammingvets.net

I want etc:
z-note.net go to htdocs/znote
skarheimdata.dyndns.org go to htdocs/skarheim
flammingvets.net go to htdocs/vets

So when you enter my site with the domains, you will load different sites.

I thought this was possible using Vhost (virtual host) on xampp.

I have tried several things, like:

Code: Select all
<VirtualHost *:80>
      DocumentRoot "C:/xampplite/htdocs/znote/"
      ServerName z-note.net
      DirectoryIndex index.php
</VirtualHost>

<VirtualHost *:80>
      DocumentRoot "C:/xampplite/htdocs/opensim/"
      ServerName skarheimdata.dyndns.org
      DirectoryIndex index.php
</VirtualHost>

When I try this, I will get redirected to the folder named znote in htdocs. Even if I am using the skarheimdata-dyndns.org IP! :(

Note that I have already bought the domains, thats not the problem. I can use the domains, but I got all the domains redirected to the same IP (host), and I heard it was possible to make the host separate the domains by using virtual hosts.

I have tryed to google it but it seems like I got a rather unique problem, since other users dosn't seem to use same host with two separate domains.

Re: Adding several domains tosame host with different root vhost

PostPosted: 20. October 2009 12:48
by Nobbie
Did you read the Apache Documentation about VirtualHosts using same IP? It is called "NameBased" VirtualHost

>I have tryed to google it but it seems like I got a rather unique problem

No, you dont have a rather unique problem, you simply have an incomplete declaration of vhosts.

See http://httpd.apache.org/docs/2.2/en/vho ... based.html

Re: Adding several domains tosame host with different root vhost

PostPosted: 21. October 2009 03:05
by Izzy
Znote wrote:...When I try this, I will get redirected to the folder named znote in htdocs. Even if I am using the skarheimdata-dyndns.org IP!
Stefan, in the httpd-vhosts file in the extra folder replace your entries with these and see how they work.
Code: Select all
NameVirtualHost *:80

<VirtualHost *:80>
ServerName localhost
DocumentRoot "C:/xampplite/htdocs"
</VirtualHost>

<VirtualHost *:80>
ServerName z-note.net
DocumentRoot "C:/xampplite/htdocs/znote"
</VirtualHost>

<VirtualHost *:80>
ServerName skarheimdata.dyndns.org
DocumentRoot "C:/xampplite/htdocs/opensim"
</VirtualHost>
Save the file and restart Apache.

Test again.

If your vhost file has errors then it will usually load the first vhost which is the default host.

BTW Stefan, an Advanced search of this XAMPP for Windows forum looking for virtualhost or vhost will give far better results that any Google can dish up.

Good luck.

Re: Adding several domains tosame host with different root vhost

PostPosted: 21. October 2009 09:05
by Znote
Thank you so much! Will try it out now. :) Sorry for my mistake.

edit:
Thank you so much Izzy, I am really happy now! Thanks for your great example! It worked! :D

Re: Adding several domains tosame host with different root vhost

PostPosted: 26. October 2009 00:57
by Tim Dawson
I have the same problem (I think). I have edited httpd.vhosts.conf, adding:

#Use name-based virtual hosting.
NameVirtualHost *:80

<VirtualHost *:80>
ServerName localhost
DocumentRoot "D:/xampp/htdocs"
</VirtualHost>

<VirtualHost *:80>
ServerName www.hmicom
ServerAlias hmicom
DocumentRoot "D:/websites/hmicom"
</VirtualHost>

The default localhost opens OK with my default Home Page, but 'http://hmicom' gives the 403 error (Access Denied). There's no password set for this directory, and there's certainly an index (index,html).

BTW it IS 'hmicom', NOT 'hmi.com'

I've also edited HOSTS:
127.0.0.1 localhost
127.0.0.1 www.hmicom
127.0.0.1 hmicom

Any suggestions, please ?

Re: Adding several domains tosame host with different root vhost

PostPosted: 26. October 2009 03:45
by Izzy
Tim, yours is a different problem.

Tim Dawson wrote:...but 'http://hmicom' gives the 403 error (Access Denied).
This is because you have not given access permissions for the directory D:\websites\hmicom which, because it is outside the htdocs tree, has no access rights as per the httpd.conf file, for obvious security reasons.
Code: Select all
NameVirtualHost *:80

<VirtualHost *:80>
    ServerName localhost
    DocumentRoot "D:/xampp/htdocs"
</VirtualHost>

<VirtualHost *:80>
    ServerName hmicom
    ServerAlias www.hmicom
    DocumentRoot "D:/websites/hmicom"
<Directory "D:/websites/hmicom" >
    Options Indexes FollowSymLinks Includes ExecCGI
    AllowOverride All
    Order allow,deny
    Allow from all
</Directory>
</VirtualHost>
Your Windows hosts file looks OK.

Re: Adding several domains tosame host with different root vhost

PostPosted: 26. October 2009 10:16
by Tim Dawson
Izzy wrote:Tim, yours is a different problem.

Tim Dawson wrote:...but 'http://hmicom' gives the 403 error (Access Denied).
This is because you have not given access permissions for the directory D:\websites\hmicom which, because it is outside the htdocs tree, has no access rights as per the httpd.conf file, for obvious security reasons.

Your Windows hosts file looks OK.

Thank you, Izzy. It works now.

Regards,

Tim