redbullmarky Posted March 22, 2008 Share Posted March 22, 2008 Hi all When working locally, I keep all my sites in a 'web' subdirectory, in a directory of their own. Each time I set up a new site, I have to add a line to my hosts.txt (eg, myproject.localhost) and also set up a vhost such as: <VirtualHost *:80> DocumentRoot "D:/web/projects/myproject" ServerName myproject.localhost </VirtualHost> before restarting the server. now, as I always follow the same pattern with naming, what i'm wondering - is it possible to wildcard the relevent places such that ALL requests to 'myproject.localhost' automatically know which correct DocumentRoot and ServerName to set up? Whilst it's not difficult to set up manually, it'd be much better for me if this was automated - apart from making it easier, it'd mean that any old sites wont require any tidying up of vhosts/hosts.txt file. Cheers Mark Quote Link to comment https://forums.phpfreaks.com/topic/97354-automatically-route-local-sites-to-correct-place/ Share on other sites More sharing options...
redbullmarky Posted March 22, 2008 Author Share Posted March 22, 2008 i may have posted a little quick for part of it. i managed to get apache set up with: UseCanonicalName Off VirtualDocumentRoot "D:/web/%1" at the end of my vhosts file. however, i still need to add these to my hosts file. is it possible to automatically have all *.localhost requests go to my local webserver? Quote Link to comment https://forums.phpfreaks.com/topic/97354-automatically-route-local-sites-to-correct-place/#findComment-498157 Share on other sites More sharing options...
wildteen88 Posted March 22, 2008 Share Posted March 22, 2008 I have a read of Dynamically configured mass virtual hosting from the manual. Seems promising. Not sure about the hosts file though, I dont think .localhost will work though. Quote Link to comment https://forums.phpfreaks.com/topic/97354-automatically-route-local-sites-to-correct-place/#findComment-498160 Share on other sites More sharing options...
redbullmarky Posted March 22, 2008 Author Share Posted March 22, 2008 yeah managed to find it once i had a proper name for what i was looking for thanks Quote Link to comment https://forums.phpfreaks.com/topic/97354-automatically-route-local-sites-to-correct-place/#findComment-498165 Share on other sites More sharing options...
trq Posted March 24, 2008 Share Posted March 24, 2008 The only was Ive found to avoid adding new sites to your hosts file is to setup a local DNS server. I'm not sure whats around for windows but Bind was a fairly straight forward setup on Linux. Of course the other thing you could do would be simply to script the entire process. Then it could be as simple as... addsite foo.localhost Which would then create the vhost (Never been a fan of using VirtualDocumentRoot as you can't customise logging on a per site basis), restart Apache and add the entry to your hosts file. Quote Link to comment https://forums.phpfreaks.com/topic/97354-automatically-route-local-sites-to-correct-place/#findComment-499405 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.