Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

In Apache2 I would like to dynamically Alias urls like this:

Alias /foo /etc/myapp/foo/www

Alias /bar /etc/myapp/bar/www

Alias /noob /etc/myapp/noob/www

and so forth, where /xxx is any existing directory under /etc/myapp that contains a subdirectory 'www'. Is this possible in Apache2?

share|improve this question
up vote 2 down vote accepted

Depends on what you want, you can do it with mass virtual hosting, mod_rewrite, or simple shell script:

for d in `ls -l /etc/myapp | grep '^d' | awk '{ print $9 }'`; do 
    if [ `ls -l /etc/myapp/"$d" | grep '^d' | grep -c www` -eq 1 ]; then 
        echo "Alias /$d /etc/myapp/$d/www" >> /path/to/httpd.conf

Could you please explain your situation a little more?

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.