Jump to content

Please Help Me Set Up Subdomains!


ddggttff3

Recommended Posts

Hello, I own a domain and I need help setting up subdomains. I want it to be so when people go to  a certain sub-domain, it will go to a diffrient webroot folder. Like this

 

mydomain.com points to C:\htdocs\

I want to make it so it does that and

hi.mydomain.com points to C:\hi_htdocs\ or whatever

 

Please Help! thanks!

 

Link to comment
Share on other sites

Its really quite simple. usually at the end of your httpd.conf file will be a line that reads...

 

NameVirtualHost *

 

After that line you can define vhosts, one after the other, each with a <VirtualHost></VirtualHost> container.

 

Examples...

 

<VirtualHost *>
   ServerName foo.com
   DocumentRoot /var/www/foo.com/htdocs
</VirtualHost>

<VirtualHost *>
   ServerName bar.com
   DocumentRoot /var/www/bar.com/htdocs
</VirtualHost>

<VirtualHost *>
   ServerName sub.bar.com
   DocumentRoot /var/www/sub.bar.com/htdocs
</VirtualHost>

 

Note these a stripped down but working examples.

 

Be aware that the first virtual host becomes the default. So gievn that the above define foo.com, bar.com and sub.bar.com if the domain boo.com points to your server then foo.com will be served as default.

 

It is the DocumentRoot directive that sets the path to each sites document root funnily enough.

Link to comment
Share on other sites

OK, heres my situation. I have a server running apache 2.2.8 and the server has 1 IP address. I own a domain (il call it domain.com) and right now when i go to my domint, it points to my IP and shows my site, well heres what i would like. Id like it to keep doing that, but I also want it so when i go to hello.domain.com it can point to my IP address, and apache will use a diffriend htdocs folder. so like having 2 sites on 1 server.

Link to comment
Share on other sites

Thorpe's suggestion should work. Make sure you have setup the DocumentRoot directives properly. The folders must exists first before Apache is restarted.

 

Replace /var/www/foo.com/htdocs to where ever your sites are located, eg C:/sites/foo.com/htdocs.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.