I was wondering if there is any Apache directive to automatically add a given prefix to all RewriteRule patterns (and possibly also RewriteCond patterns), similar to RewriteBase for substitutions of relative urls.
To put this into a context - I want to run my php application under a url sub-folder, say we http://example.com/my-app/
. In the Apache virtual host I set
Alias /myapp "<path-to-my-app-source-dir>"
as I want to run a different app under http://example.com
. In the .htaccess
under the my-app source folder, I added RewriteBase /my-app
so I don't have to explicitly put my-app
in RewriteRule substitutions. I haven't found any similar directive to specify prefix for patterns, so the following rules
RewriteRule ^my-app/foo/(.+)$ foo.php?x=$1
RewriteRule ^my-app/.*$ index.php [L]
could be specified as
RewriteRule ^foo/(.+)$ foo.php?x=$1
RewriteRule ^.*$ index.php [L]
Is there one? Or is there overall a better solution for this set up?
Thanks!