I am using this rule:
RewriteRule !^(.*?/.*|.*?\.(?:php|html)$)$ headers.php?a=$1 [L]
(based on the great contributions on Regex match this OR that?)
It rewrites to headers.php when I type localhost/foo but the a variable is empty instead of foo (I checked with var_dump($_REQUEST))
Any idea why? I tried using
RewriteCond %{REQUEST_URI} !headers
but it wasn’t that.
Thank you!
The rule is negated, so it is executed if and only if the regular expression doesn’t match the URI being processed. Since the capturing group doesn’t match
localhost/foo, there’s nothing for the regex engine to put into$1. The solution is to avoid the use of negation in yourRewriteRuledirective, and instead useRewriteConddirectives to check the negated regex. The following ruleset should work. (I haven’t test it, though. It’s possible that there’s a mistake somewhere.)