Is there a way to get back references for Rewrite Conditions to be passed to all subsequent rewrite rules?
Here's an example:
RewriteEngine On
RewriteCond %{HTTP_HOST} (bob).localhost [NC]
RewriteRule ^/where/? /index.php\?user_name=%1
RewriteRule ^/who/? /index.php\?user_name=%1
In this example I would expect this behavior:
http://bob.localhost/where => http://bob.localhost/where/index.php?user_name=bob
http://bob.localhost/who => http://bob.localhost/who/index.php?usern_ame=bob
But for the second rule I receive http://bob.localhost/who/index.php?user_name= instead.
I've tried this on several different distro's using Apache 2.2.17
Conditions only apply to the very next rule. You'll need to repeat the condition in order for it to apply to another rule:
In your example, if your request's HTTP_HOST value doesn't match
(bob).localhost
, your request will skip the^/where/?
rule (even if it matches), but can use the^/who/?
rule.As DerfK indicates, rewritecond is for only one rewrite rule.
You might consider an alternate strategem however, setting and reading environment variables.