logo
Apache Lounge
Webmasters

 

About Forum Index Downloads Search Register Log in RSS X


Keep Server Online

If you find the Apache Lounge, the downloads and overall help useful, please express your satisfaction with a donation.

or

Bitcoin

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.
Post new topic   Forum Index -> Apache View previous topic :: View next topic
Reply to topic   Topic: Help with multiple websites, virtualhosts?
Author
dannyhines



Joined: 22 May 2007
Posts: 3

PostPosted: Tue 22 May '07 21:44    Post subject: Help with multiple websites, virtualhosts? Reply with quote

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: 7298
Location: Germany, Next to Hamburg

PostPosted: Wed 23 May '07 9:45    Post subject: Reply with quote

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 Wink

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

PostPosted: Wed 23 May '07 14:44    Post subject: Reply with quote

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

PostPosted: Thu 24 May '07 7:33    Post subject: Reply with quote

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


Reply to topic   Topic: Help with multiple websites, virtualhosts? View previous topic :: View next topic
Post new topic   Forum Index -> Apache