I am trying to write a redirect rule that says "If the HTTP_REFERER contains a certain QUERY_STRING, do this..."

In other words, I have this scenario:

HTTP_REFERER: http://www.example.com/admin.php?foo=bar

... and I would like to say, "If the HTTP_REFERER contains the QUERY_STRING 'foo=bar', do this..." Make sense? Lol

Maybe it's not even possible? I'm relatively new to mod_rewrite.

link|improve this question

1  
If you work out your own solution, just post it as an answer. Don't delete a good resource. – random Oct 3 '09 at 15:45
feedback

2 Answers

up vote 0 down vote accepted

As it turns out, the QUERY_STRING is already a part of the HTTP_REFERER.

So the solution is simple:

RewriteCond %{HTTP_REFERER} !foo=bar
link|improve this answer
feedback

Try this RewriteCond:

RewriteCond %{HTTP_REFERER} ^[^?]+\?([^&]*&)*foo=bar(&.*)?$
link|improve this answer
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.