I have working localhost on my Fedora 15. Directory tree look like this

/var/www/html/default

/var/www/html/projects
             /projects/foo
             /projects/bar

/var/www/html/devel
             /devel/foo
             /devel/bar

For each project is created vhost conf which points to:

localhost  > /var/www/html/default
devel      > /var/www/html/projects
foo.devel  > /var/www/html/projects/foo
dev        > /var/www/html/devel
foo.dev    > /var/www/html/devel/foo

What I need is to make it a little bit automated. So when i make folder 'bar' in the 'projects' directory, it will be accessible like 'bar.devel'. How to do this? mod_vhost_alias and mod_rewrite are loaded so I will try both version.

Thank You!

// edit have played little bit with mod_vhost_alias

<VirtualHost *:80>
    UseCanonicalName Off
    ServerAlias *.devel
    VirtualDocumentRoot /var/www/html/projects/%1
</VirtualHost>

looks pretty nice.. but still is needed to make a record in /etc/hosts for each project

127.0.0.1 foo.devel
127.0.0.1 bar.devel
link|improve this question
Changing Apache config won't enable DNS lookups. You will have to add each entry to your /etc/hosts file even with Apache configured the way you have (Unless you set up an internal DNS server to respond to *.devel requests) – sam Jul 28 '11 at 12:05
I tried to add in /etc/hosts 127.0.0.1 *.devel but it redirects me to www.foo.devel instead of foo.devel. So i need internal DNS server.. hmmm.. – 5ulo Jul 28 '11 at 12:43
Wildcards don't work in the standard hosts file, however someone wrote a Python script which can make them work - code.google.com/p/marlon-tools/source/browse/tools/dnsproxy/… Setting up an internal DNS server isn't particually hard (Look up DNSMasq or MyDNS) but if you can get that python script to work I'd suggest that's the easyer option – sam Jul 28 '11 at 12:47
I would suggest setting up a local DNS server for the development server. This can be done quite quickly. Then u need to add the wildcard for the devel domain (*.devel ip_of_your_server). This way the apache2 redirects u have written will work. – Goez Jul 28 '11 at 12:51
DNSMasq did the job :) Thanks! – 5ulo Jul 28 '11 at 13:42
show 1 more comment
feedback

Know someone who can answer? Share a link to this question via email, Google+, Twitter, or Facebook.

Your Answer

 
or
required, but never shown

Browse other questions tagged or ask your own question.