banning nonenglish characters in url

revekozu

Junior Member
Joined
Jul 30, 2010
Messages
133
Reaction score
41
First off. No offense to our non English speaking friends. I just can't monetize this traffic and also fear an adsense ban for the site.

The site uses a search parameter at the end of certain urls an gradually it has been flooded with foreign language searches. I don't wan to do country bans by ip. But maybe limiting the unicode charset somehow via htaccess could work.

or here is the start of a different solution using htacess

Code:
RewriteEngine On

# Block access when 'ஷ்' in url

RewriteCond %{REQUEST_URI} .*ஷ்.* [NC]
RewriteRule ^(.*)$ $1 [F,L]

and this works when that character is in a searched word. I'm tempted to ask how to put more characters from words in my logfiles like that in an array. But surely there is a better way to exclude characters beyond the range 0-127?


(I really suck at figuring out htaccess and always end up begging for help somewhere... but hopefully others learn from my questions)
 
This regex matches non-english characters. mod_rewrite uses regular expressions, so...
Cool. Can't wait to try it. Well actually I do have to wait...things to do...but asap.
 
Works like a charm. Decided to redirect to home page. May as well keep any link juice.

Final code for any one else.

Code:
RewriteEngine On

# Redirect access when '[^\x00-\x80]+' in string


RewriteCond %{REQUEST_URI} .*[^\x00-\x80]+.* [NC]
RewriteRule ^/* http://www.mysite.net/ [L]
 
Last edited:
Back
Top