Keep Server Online
If you find the Apache Lounge, the downloads and overall help useful, please express your satisfaction with a donation.
or
A donation makes a contribution towards the costs, the time and effort that's going in this site and building.
Thank You! Steffen
Your donations will help to keep this site alive and well, and continuing building binaries. Apache Lounge is not sponsored.
| |
|
Topic: Help with multiple websites, virtualhosts? |
|
Author |
|
dannyhines
Joined: 22 May 2007 Posts: 3
|
Posted: Tue 22 May '07 21:44 Post subject: Help with multiple websites, virtualhosts? |
|
|
Hey there. I'm pretty new to apache and running my own webserver in general. Right now I'm just doing this all to simply learn how everything works. I'm running Apache 2.2 on a Windows XP computer on my home connection.
I finally got everything working correctly, for the most part. I set up my domain name so that it resolves to my IP address. The next step I want though, is to be able to setup multiple domains to go to different folders on my webserver, and also for subdomains to work correctly.
I want for example:
www.mywebsite1.com -> htdocs/mywebsite1
www.mywebsite2.com -> htdocs/mywebsite2
pics.mywebsite1.com -> htdocs/mywebsite1/pics
I followed a guide on creating virtual hosts and thought that I did everything correctly, but unfortunately everything goes to the root folder. No matter what subdomain I put in, the same page opens and it does not pull from the specific folder that I want.
This has to be a pretty common thing right??? Any help is appreciated. |
|
Back to top |
|
James Blond Moderator
Joined: 19 Jan 2006 Posts: 7371 Location: Germany, Next to Hamburg
|
Posted: Wed 23 May '07 9:45 Post subject: |
|
|
Code: |
NameVirtualHost *:80
<VirtualHost *:80>
ServerName www.domain.tld
ServerAlias domain.tld *.domain.tld
DocumentRoot /www/domain
</VirtualHost>
<VirtualHost *:80>
ServerName www.otherdomain.tld
DocumentRoot /www/otherdomain
</VirtualHost>
|
Most stuff can be found in the docs
But you also have to configure the DNS, that all the names pointing to your IP address. |
|
Back to top |
|
dannyhines
Joined: 22 May 2007 Posts: 3
|
Posted: Wed 23 May '07 14:44 Post subject: |
|
|
I followed the guide for setting up Virtual hosts first, but obviously missed something. The code you posted is pretty much exactly what I have right now.
The DNS is configured and that is not a problem. All my domains are set to resolve to my IP. But no matter what domain of mine I type into the browser, it always pulls up the same page from my root htdocs directory, instead of the document root assigned to that specific virtual host.
This is getting really frustrating, what am I missing???
Code: |
NameVirtualHost 24.16.***.***:80
<VirtualHost 24.16.***.***:80>
ServerName www.domain1.com
DocumentRoot "C:/Program Files/Apache Software Foundation/Apache2.2/htdocs/domain1"
DirectoryIndex index.php index.html index.htm
ServerAlias domain1.com
</VirtualHost>
<VirtualHost 24.16.***.***:80>
ServerName www.domain1.com
DocumentRoot "C:/Program Files/Apache Software Foundation/Apache2.2/htdocs/domain1/pictures"
DirectoryIndex index.php index.html index.htm
ServerAlias domain1.com pictures.domain1.com
</VirtualHost>
<VirtualHost 24.16.***.***:80>
ServerName www.domain2.com
DocumentRoot "C:/Program Files/Apache Software Foundation/Apache2.2/htdocs/domain2"
DirectoryIndex index.php index.html index.htm
ServerAlias domain2.com
</VirtualHost>
|
|
|
Back to top |
|
dannyhines
Joined: 22 May 2007 Posts: 3
|
Posted: Thu 24 May '07 7:33 Post subject: |
|
|
oh nevermind i figured this out. I was putting in IP address of my router instead of the server's network IP |
|
Back to top |
|
|
|
|
|
|