Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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.

share|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

2 Answers 2

up vote 1 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
share|improve this answer

Try this RewriteCond:

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

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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