MC,
Code:
RewriteEngine on
RewriteCond %{HTTP_REFERER} !(www\.)?mysite\.com/ [NC,OR]
RewriteCond %{HTTP_REFERER} !(www\.)?whitelisted_site_1\.com/ [NC,OR]
RewriteCond %{HTTP_REFERER} !(www\.)?whitelisted_site_n\.com/ [NC,OR]
RewriteCond %{HTTP_REFERER} offending_domain\.com [NC]
RewriteRule .? - [F,L]
may be simplified by combining RewriteCond statements like
Code:
RewriteEngine on
RewriteCond %{HTTP_REFERER} !(www\.)?(mysite\.com/|whitelisted_site_1\.com/|whitelisted_site_n\.com/) [NC,OR]
RewriteCond %{HTTP_REFERER} offending_domain\.com [NC]
RewriteRule .? - [F]
Here, I've used the pipes within an atom to do my OR'ing for me as only one grouping needs to be matched (I left the .com in the atom as you may have a .org or .net that you want to whitelist, too, but the \.com should be moved outside the grouping parentheticals for simplicity's sake).
Actually, the second RewriteCond will be matched by the first so it's superfluous (not needed so it and the OR flag above can be deleted).
Yes, because you wanted to whitelist every member of that group, OR was correct between those conditions.
I'm happy to see that you did not OR the RewriteCond statements with the RewriteRule (which would have been a logical error).
If your list of whitelisted or banned sites expands, you may want to look into RewriteMaps (from the link above) but that does require access to the server or virtual host configuration file (because a syntactical error can bring the server down).
Regards,
DK
Bookmarks