Mix Articles

Very useful article for everyone

10
Apr 2006
Advance Referer Spam Block
Posted in Internet and Business Online by Articles Addict at 11:14 pm |

Since my last post about referer spam,, I found that I can’t block all spam!

So I find the new way to do. It’s “mod_security“. You should looking for this mod in your PHPINFO by write a small script with

< ?php
phpinfo();
?>

Then looking for mod_security. If you are not sure,, ask your administrator.

Then have this code in .htaccess file

RewriteEngine On

#################
# Turn the filtering engine On or Off
SecFilterEngine On

# Make sure that URL encoding is valid
SecFilterCheckURLEncoding On

# Unicode encoding check
SecFilterCheckUnicodeEncoding Off

# Only allow bytes from this range
SecFilterForceByteRange 0 255

# Only log suspicious requests
SecAuditEngine RelevantOnly

# Should mod_security inspect POST payloads
SecFilterScanPOST On

# SecAuditLog logs/audit_log
# Not sure what my host would think of that...
SecFilterDefaultAction "deny,status:412"

#ALLOW list  - put the ip address list in this line
# and seperate with | (pipe)
SecFilterSelective "REMOTE_ADDR" "11.11.111.11" "allow,nolog"

# Block request with suspicious referers
SecFilterSelective "HTTP_REFERER" "(free-websites|sapo|porkyhost)"

# Applies the same regex as above to the payload of POST requests.
SecFilterSelective "POST_PAYLOAD" "(free-websites|sapo|porkyhost)"

#Spam user agent
SecFilterSelective "HTTP_USER_AGENT" "(hdic|bdfetch|npbot)"
RewriteEngine On

# pineapple baby - comment spammer - see below for an explanation of
# what the rewrite rule does.
RewriteOptions MaxRedirects=30
RewriteCond %{HTTP:VIA} ^.+pinappleproxy [NC]
RewriteCond %{HTTP_REFERER} ^(.*)$ [NC]
RewriteRule ^(.*)$ %1 [R=301,L]

**make sure that some ads, content you still there!

change whatever you like and test if nothing wrong with your content.


You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.

Leave a Reply