How To block Unwanted / Specific Traffic using .htaccess

How do I deny traffic from a specific IP address?
Suppose you would like to dam traffic from IP address 192.188.1.166.
Add to your .htaccess file the following line:
deny from 192.188.1.166
You can block entire networks using a similar kind of rule. to dam the whole Network 172.148.1.6-192.188.1.166:
deny from 172.148.1.6
You can use multiple lines, one for every network or host:
- deny from 192.168.1
- deny from 192.168.3.24
- deny from 192.168.5.33
See also Apache\’s mod_access page
How do I block traffic from a specific referrer?
You may need to dam traffic from explicit websites that link to your site. you\’ll perform HTTP referrer-based block using mod_rewrite.
Suppose you\’d wish to block (with a 403 forbidden code) traffic referred by hitleap.com. Add the lines to .htaccess:
RewriteEngine onRewriteCond % ^http://(www\\.)?hitleap\\.com [NC]RewriteRule (.*) – [F]
You can block multiple domains victimization multiple RewriteCond lines and also the [OR] “Flag” As Follows:
RewriteEngine onRewriteCond % ^http://(www\\.)?hitleap\\.com [NC,OR]RewriteCond % ^http://(www\\.)?easyhits4u\\.com [NC]RewriteRule (.*) – [F]
NB: make sure to feature [OR], as shown, to every RewriteCond line however the last. The default behavior could be a logical AND, i.e. the RewriteRule takes impact providing all of the RewriteCond lines apply, that you are doing not need here.
0 comments:
Post a Comment