Options -Indexes
RewriteEngine on
Options +FollowSymLinks
RewriteRule ^$ 2012/index.php [L]
RewriteCond %{DOCUMENT_ROOT}/2012%{REQUEST_URI} -f
RewriteRule .* 2012/$0 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* 2012/index.php$0 [QSA] #<-- this is wrong here, and gives 500 error
I am trying to server all my urls from the 2012 subfolder.
I tried the above script, and it fails for urls like:
index.php/admin/controller/action?id=123
which should be resolved from the subfolder
2012/index.php/admin/controller/action?id=123
what is wrong?
I’m going to guess that the URI
/index.php/admin/controller/action?id=123fails the -f test for%{DOCUMENT_ROOT}/2012%{REQUEST_URI}, and is instead getting rounded up by the last rule:RewriteRule .* 2012/index.php?q=$0 [QSA], turning the URI into/2012/index.php?q=index.php/admin/controller/action&id=123. You’ll have to add a special case for this because the first condition/rule allows the existing files to be rewritten as-is, and the last condition/rule acts as a “catch-all” (and the very first rule is simply for the special case when the request URI is/). Try something like this:The new condition
RewriteCond %{REQUEST_URI} ^/index\.php [OR]will be satisfied if a request is made starting with/index.phpand the URI gets rewritten as-is into the /2012/ directory. The [OR] ensures the previous condition of a direct access be honored.