Forum Moderators: phranque

Message Too Old, No Replies

rewrite rule doesnt seem to work?

         

kmaisch

3:52 am on Jan 13, 2006 (gmt 0)

10+ Year Member



I have quite a few RewriteCond rules in my htaccess file, and they seem to work well.

However, I have some keyword blocks for dodgy referrers, such as the word "casino", etc.

RewriteCond %{HTTP_REFERER} ^http://(www\.)?.*(-¦.)casino(-¦.).*$ [NC,OR]

For some reason this doesnt seem to work... eg, I still get lots of referrers with addresses like casinofun.com, casino-madness.com, etc.

Is there a better way to block a keyword? Maybe removing the www bit? What would be the correct way to do this?

Kim

jdMorgan

6:23 am on Jan 13, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Just using

RewriteCond %{HTTP_REFERER} casino [NC,OR]

would block that word occurring anywhere in the referring domain, page name, or even query string attached to the referring URL. It would also block any string containing that word -- casinos, casinova (misspelled, yes), etc. This is predicated on the client having sent a referrer, though.

How you do this depends on what you want to do, and every Web site is different. Your original pattern had some questionable constructions in it, so I'd suggest a review of the regular expressions tutorial cited in our forum charter [webmasterworld.com]. Only by understanding the regex patterns can you understand the function of the code. And only then can you tailor your code to do what you want, not what *I* think you want, or what anyone else here might think you want... We could easily be wrong, and it's your site that will suffer the result.

Jim

kmaisch

6:55 am on Jan 13, 2006 (gmt 0)

10+ Year Member



ahh, excellent - thanks Jim, I'll have a good read through that page (Charter).

Cheers,
kim