How To block Unwanted / Specific Traffic using .htaccess

All of the recipes below refer to AN .htaccess file. An .htaccess file could be a document named \”.htaccess\” placed in your www/ directory or any directory therefrom, with web user-readable (0644) permissions. The .htaccess file contains rules that apply to the handling of traffic to the directory containing the .htaccess file, and every one subdirectories therefrom. so as an example, if you had a rule you needed to use to your entire website, you\’d put AN .htaccess come in your www/ directory. If you needed the rule to use solely to your www/hitleap/ directory, you\’d place the .htaccess enter www/hitleap/.

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 on
RewriteCond % ^http://(www\\.)?hitleap\\.com [NC]
RewriteRule (.*)               – [F]
You can block multiple domains victimization multiple RewriteCond lines and also the [OR] “Flag” As Follows:
RewriteEngine on
RewriteCond % ^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

 
Top