Rewrite 2 different directories with htaccess?

Posted by jason on Server Fault See other posts from Server Fault or by jason
Published on 2012-10-08T20:41:48Z Indexed on 2012/10/08 21:39 UTC
Read the original article Hit count: 133

Filed under:
|

I have a tricky problem (for me at least).

I'm trying to rewrite / to a folder /webroot/www. I have some simple code and it works:

RewriteRule ^$ /webroot/www/ [L]

However at the same time if the URL starts with components, followed by anything else (ex. foo, as in /components/foo), and foo is an actual directory that exists inside components, I should rewrite to /components/foo/www instead.

How can I achieve that? I can't seem to figure it out.

I'm using Apache with .htaccess.

© Server Fault or respective owner

Related posts about apache2

Related posts about .htaccess