Reputation: 449395
Say I have three small web applications stored under a shared web root:
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?
Upvotes: 1
Views: 145
Reputation: 655219
You don’t need to specify the full path. You can use relative paths that are then resolved from the base path.
So try this rule:
RewriteRule ^([^/]+)/([^/]+)\.html$ index.php?selectedProfile=$1&match=$2 [QSA]
You could even use just this single rule in your document root directory:
RewriteRule ^(app\d+)/([^/]+)/([^/]+)\.html$ $1/index.php?selectedProfile=$2&match=$3 [QSA]
Upvotes: 2