Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have this url:

I would like to block this specific url but not in any way affect other query strings on the same base url.

Is it possible to do this?


share|improve this question

You can use ModRewite to check for query strings and redirect or block a page. Using your example:

RewriteCond %{QUERY_STRING} var=var
RewriteCond %{QUERY_STRING} date=12/12/12
RewriteCond %{QUERY_STRING} var2=word\+word
RewriteRule .* - [F]

(There's an implicit AND between the RewriteCond statements)

This would block ([F]) all pages (.*) that had all three of those querystring parameters and values.

UPDATED to use more specific examples by the OP

share|improve this answer
Perfect, thanks! – rix Dec 20 '11 at 15:58
Actually, that doesn't appear to work - any other ideas? – rix Dec 20 '11 at 16:16
It worked in my local Apache install. Is RewriteEngine On? What happens when you hit the URL above? – lvmisooners Dec 20 '11 at 16:19
@rix Keep in mind that there may be characters in your string that need to be escaped with a ` when used in a regex. If this doesn't work, try setting a RewriteLog` and turn RewriteLogLevel to 9, and let us know what that gives you. – Shane Madden Dec 20 '11 at 16:22
Ah right, I have / in the var ie a date=12/12/12 and other than that just + for spaces. ie var=word+word - does the + and the / need to be escaped? – rix Dec 20 '11 at 16:30

Your Answer


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.