Adding several domains tosame host with different root vhost

Problems with the Windows version of XAMPP, questions, comments, and anything related.

Adding several domains tosame host with different root vhost

Postby Znote » 20. October 2009 11:32

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.
Znote
 
Posts: 20
Joined: 17. November 2008 18:15

Re: Adding several domains tosame host with different root vhost

Postby Nobbie » 20. October 2009 12:48

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
Nobbie
 
Posts: 13179
Joined: 09. March 2008 13:04

Re: Adding several domains tosame host with different root vhost

Postby Izzy » 21. October 2009 03:05

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.
Izzy
 
Posts: 3344
Joined: 25. April 2006 17:06

Re: Adding several domains tosame host with different root vhost

Postby Znote » 21. October 2009 09:05

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
Znote
 
Posts: 20
Joined: 17. November 2008 18:15

Re: Adding several domains tosame host with different root vhost

Postby Tim Dawson » 26. October 2009 00:57

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 ?
ramasaig
Isle of Mull, Scotland

OS=WinXP Home SP2
Tim Dawson
 
Posts: 27
Joined: 26. January 2007 13:34
Location: Fionnphort, Isle of Mull

Re: Adding several domains tosame host with different root vhost

Postby Izzy » 26. October 2009 03:45

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.
Izzy
 
Posts: 3344
Joined: 25. April 2006 17:06

Re: Adding several domains tosame host with different root vhost

Postby Tim Dawson » 26. October 2009 10:16

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
ramasaig
Isle of Mull, Scotland

OS=WinXP Home SP2
Tim Dawson
 
Posts: 27
Joined: 26. January 2007 13:34
Location: Fionnphort, Isle of Mull


Return to XAMPP for Windows

Who is online

Users browsing this forum: No registered users and 198 guests