Use apache to block a url with specific query string

apache-2.2querystringrewrite

I have this url:

mysite.com?var=var&var2=var2&var3=var3

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?

Thanks,

Best Answer

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