The "not operator" ! not working in .htaccess

I’m getting my feet wet with mod_rewrite.
What I’m trying to accomplish is to only allow a specific querystring and disallow all others but am getting very confused.


RewriteEngine On
# just commented these to show what I also tried.
#RewriteCond %{QUERY_STRING} !id=1234 
#RewriteRule .* /index.php? [R=301,L]

RewriteCond %{QUERY_STRING} !id=1234 
RewriteCond %{QUERY_STRING} ^$
RewriteRule .* /index.php? [R=301,L]

Reading online I see the exact same thing I have with the !id=1234 and people say it works for them. It redirects if there is no query string but I can enter ?poi=poi and there is no redirect.

Thank you.

loren,

RewriteCond statements are ANDed by default to your code is: If query_string != “id=1234” AND query_strong IS null, redirect to index.php. In other words, use the OR flag at the end of your first RewriteCond statement.

You may find this in the sticky threads or the original linked in my signature.

BTW: If you’re not not using the .* (which you are not), then merely use .? in the RewriteRule’s regex for efficiency.

Regards,

DK

Thank you, got things working and am happy (for the moment).