Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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

1 Answer 1

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
    fi 
done

Could you please explain your situation a little more?

share|improve this answer

Your Answer

 
discard

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.