RewriteRule ^resources/.+$ - [L]
RewriteRule .? index.php?t=$0 [QSA,L]
Would produce a 500 - Internal Server Error, because it would repeat again and again the same rule, due to internal redirected requests which are exactly treated as the first one. It would lead to an infinite chain of index.php?t=index.php&t=index.php&t=index.php&[...infinite more...]&t=test.php
But in my opinion this is not much better:
RewriteRule ^resources/.+$ - [L]
RewriteCond %{QUERY_STRING} !t=
RewriteCond %{REQUEST_URI} !^index\.php$
RewriteRule .? index.php?t=$0 [QSA,L]
Because now the user could input index.php?t=test.php as address, would pass the script and get the same content as if he had given test.php. I don’t like that.
So how do I execute the first one without the issue of repeating internal redirects?
Surely, a flag VL – Very Last would do the trick but sadly it does not exist.
First we have a look at all parameters given to the rules possibly indicating whether this is a chained request or not. This means, we either 1) need a variable changed in chained requests not relative to the changed URI or 2) the opposite, a variable which is relative to the changed URI and did not change (because we can compare it then against the others who did chage).
The problem is, they almost all update according to the applied
RewriteRules.IS_SUBREQ(1) andTHE_REQUEST(2) are the only interesting variables but sadly internal redirects are not treated as subrequests, soIS_SUBREQdisappears. OnlyTHE_REQUESTdoes not change and contains the real given path, so we have found our entry point.With this in mind here is the annoying complex solution: