Forum Moderators: phranque

Message Too Old, No Replies

is this up to date for banning a referrer site

         

leoo24

11:25 am on Feb 14, 2004 (gmt 0)

10+ Year Member



setenvifnocase Referer "^http://www.sitethatiwantotblockreferresfrom.com" spam_ref=1

<FilesMatch "(.*)">
Order Allow,Deny
Allow from all
Deny from env=spam_ref
</FilesMatch>

what would i do to add more than one? repeat the referer line "referer"^http..." and change it to spam-ref=2?

cheers:)

what would the mode_rewrite be for banning people from a certain refferer?

jdMorgan

7:06 pm on Feb 15, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



leoo24,

Just add as many SetEnvIf directives as you like; They are effectively ORed together, since any one of them can "set" the variable. Note that you do not have to assign a value to the variable at all -- it will be set to logical "true" by default. Also, remember to "escape" the literal characters in the regex string by preceding them with a backslash:


SetEnvIfNoCase Referer "^http://www\.sitethatiwantotblockreferresfrom\.com" spam_ref
SetEnvIfNoCase Referer "^http://www\.othersitethatiwantotblockreferresfrom\.com" spam_ref
SetEnvIfNoCase Referer "^http://www\.yetanothersitethatiwantotblockreferresfrom\.com" spam_ref

The mod_rewrite code takes a similar form:


RewriteCond %{HTTP_REFERER} ^http://www\.sitethatiwantotblockreferresfrom\.com [NC,OR]
RewriteCond %{HTTP_REFERER} ^http://www\.othersitethatiwantotblockreferresfrom\.com [NC,OR]
RewriteCond %{HTTP_REFERER} ^http://www\.yetanothersitethatiwantotblockreferresfrom\.com [NC]
RewriteRule !^yourcustom403page\.html$ - [F]

Note that the pattern in the RewriteRule excludes redirects on requests for your custom 403 error page if you have one, and that the last RewriteCond *must not* have an [OR] flag on it.

Ref: Introduction to mod_rewrite [webmasterworld.com]

Jim

leoo24

7:26 pm on Feb 16, 2004 (gmt 0)

10+ Year Member



thanks jim :)