Building path independent mod_rewrite statements for generic .htaccess file
        Posted  
        
            by Pekka
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by Pekka
        
        
        
        Published on 2010-04-10T18:58:34Z
        Indexed on 
            2010/04/10
            19:03 UTC
        
        
        Read the original article
        Hit count: 388
        
Say I have three small web applications stored under a shared web root:
www.example.com/app1/ www.example.com/app2/ www.example.com/app3/ www.example.com/app4/
each application has a .htaccess file containing some run-off-the-mill mod_rewrite statements to rewrite urls like
RewriteCond %{REQUEST_URI} ^/app1/([^/]+)/([^/]+)\.html$
RewriteRule .* /app1/index.php?selectedProfile=%1&match=%2&%{QUERY_STRING}
now, I would like to have a generic .htaccess file in each /app{n} directory. So, no RewriteBase and no /app{n} prefix in the RewriteConds. 
One idea I had was making the first level a wildcard directory as well:
RewriteCond %{REQUEST_URI} ^/([^/]+)/([^/]+)/([^/]+)\.html$
seeing as the .htaccess file gets triggered only when the /app{n} directory is entered, this should work.
Is this an acceptable solution?
Are there other, better ones?
© Stack Overflow or respective owner