3

Is it possible to check for X and (Y or Z) with mod_rewrite?

I have the following rule to serve dummy.png to guests of my website, who don't have 2 cookies id and auth set (I set those in my custom Drupal module for registered users):

   RewriteCond %{REQUEST_URI} ^/sites/default/files/pictures/picture-
   RewriteCond %{HTTP_COOKIE} !auth [OR]
   RewriteCond %{HTTP_COOKIE} !id
   RewriteRule .+ /images/dummy.png [L]

but I'm not sure if it works as intended (maybe it acts as (X and Y) or Z instead?)

Alexander Farber
  • 21,519
  • 75
  • 241
  • 416

1 Answers1

1

You can let the RewriteRule handle the URI pattern matching. No need to do that in a RewriteCond. For other URLs, the first two conditions may match, but the rule itself won't and no rewrite will take place.

RewriteCond %{HTTP_COOKIE} !auth [OR]
RewriteCond %{HTTP_COOKIE} !id
RewriteRule ^/sites/default/files/pictures/picture-.+ /images/dummy.png [L]
whoisgregg
  • 75
  • 10