ddggttff3 Posted July 22, 2008 Share Posted July 22, 2008 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! Quote Link to comment Share on other sites More sharing options...
vikramjeet.singla Posted July 22, 2008 Share Posted July 22, 2008 you can use virtual hosts for this.... please refer to httpd manual for more details on virtual hosts Quote Link to comment Share on other sites More sharing options...
ddggttff3 Posted July 22, 2008 Author Share Posted July 22, 2008 i did, but i dont understand it when I try it, apache crashes. what i need is an example to edit to my settings. Quote Link to comment Share on other sites More sharing options...
trq Posted July 22, 2008 Share Posted July 22, 2008 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. Quote Link to comment Share on other sites More sharing options...
ddggttff3 Posted July 22, 2008 Author Share Posted July 22, 2008 ok, so if I do that, and i set the subdomain sub.bar.com to my IP, will it go to that specified folder? of will it go to the main domian? Quote Link to comment Share on other sites More sharing options...
ddggttff3 Posted July 22, 2008 Author Share Posted July 22, 2008 doesnt work for me... apache wont start. Quote Link to comment Share on other sites More sharing options...
trq Posted July 22, 2008 Share Posted July 22, 2008 Post what you have. Quote Link to comment Share on other sites More sharing options...
ddggttff3 Posted July 22, 2008 Author Share Posted July 22, 2008 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. Quote Link to comment Share on other sites More sharing options...
wildteen88 Posted July 22, 2008 Share Posted July 22, 2008 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. Quote Link to comment Share on other sites More sharing options...
trq Posted July 22, 2008 Share Posted July 22, 2008 You'll also need to setup a wildcard CNAME record in your DNS (usually set wherever your domain name is setup). But yeah, as I said, post what you have. Quote Link to comment Share on other sites More sharing options...
ddggttff3 Posted July 22, 2008 Author Share Posted July 22, 2008 i did, but it still didnt start Quote Link to comment Share on other sites More sharing options...
trq Posted July 22, 2008 Share Posted July 22, 2008 Post what you have! Quote Link to comment Share on other sites More sharing options...
ddggttff3 Posted July 22, 2008 Author Share Posted July 22, 2008 you mean my httpd.conf file? Quote Link to comment Share on other sites More sharing options...
trq Posted July 22, 2008 Share Posted July 22, 2008 you mean my httpd.conf file? Just the relevent vhost entries. Quote Link to comment Share on other sites More sharing options...
ddggttff3 Posted July 22, 2008 Author Share Posted July 22, 2008 I used this <VirtualHost *> ServerName uberforumz.com DocumentRoot C:/xampp/htdocs </VirtualHost> <VirtualHost *> ServerName files.uberforumz.com DocumentRoot C:/xampp/htdocs/files </VirtualHost> Quote Link to comment Share on other sites More sharing options...
trq Posted July 22, 2008 Share Posted July 22, 2008 And they come after the... NameVirtualHost * line? The directories exist? Shouldn't be a problem. Have you checked the apache error logs? Quote Link to comment Share on other sites More sharing options...
ddggttff3 Posted July 22, 2008 Author Share Posted July 22, 2008 ther error log has nothin Edit: got it workin, thanks for all of the help! Quote Link to comment Share on other sites More sharing options...
trq Posted July 22, 2008 Share Posted July 22, 2008 What was the problem? Quote Link to comment Share on other sites More sharing options...
ddggttff3 Posted July 23, 2008 Author Share Posted July 23, 2008 a incorrest settin in httpd.conf. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.