Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Subdomain help 1

Status
Not open for further replies.

RandyRiegel

Programmer
Joined
Sep 29, 2003
Messages
256
Location
US
I am running an experimental webserver for fun out of my home. I have a domain name and DNS setting pointing to my home IP address. Also, setup a subdomain with my DNS provider which points to same IP address. My main site ( is stored at /var/
What do I have to do to the httpd.conf file to get this to work? I've tried the following:
Code:
<VirtualHost *>
    DocumentRoot /var/[URL unfurl="true"]www/html/sub1[/URL]
    ServerName sub1.mydomain.com
</VirtualHost>

After adding the above code I can type and it displays what should be I want to show the main site and to show what is in that directory. Am I on the right track?

Randy
 
You're getting close...

Once you create a virtual host, your 'main' server goes away. You now need 2 virtual hosts:
Code:
<VirtualHost *>
  DocumentRoot /var/[URL unfurl="true"]www/html[/URL]
  ServerName mydomain.com
</VirtualHost>
<VirtualHost *>
  DocumentRoot /var/[URL unfurl="true"]www/html/sub1[/URL]
  ServerName sub1.mydomain.com
</VirtualHost>

If apache can't figure out the servername that is being requested, it serves up the first virutal host; which is the behavior that you're seeing. Also, be sure to read the VirtualHost FAQ's in this forum for more info.
 
Thanks alot, I just put my main domain and a vhost and it works great now. Thanks

Randy
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top