Skip to content Skip to sidebar Skip to footer

How to block referrers or IP websites via .htaccess

Blocking a website or IP that is interfering with the website itself is a fair way to go. What is done is quite simple and without a long script, because it is enough to rely on one very important file from a website, namely: .htaccess. The file has many uses across the website system and incorrect editing can lead to errors.

.htaccess has many functions like ModRewrite who can optimize the website better, such as URL optimized used for SEO on search engines. In addition to being used for SEO, Modrewrite can also be used to block referrals from other websites going to their own website.

Referrer basically is Followers / Inviteers and on the website we can see with the help of Javascript or PHP. Referrers can be manipulated with referrer headers and various programming systems almost all support editing their own referrer headers and others. Sometimes there are websites that take over content from their own website. So you need to create a referrer log in which all referrer URL data is stored. And if there is a url interfering with the website, please block url with help .htaccess. Here is the code.!

RewriteEngine onRewriteCond %{HTTP_REFERER} ^http://.*situstarget.com [NC,OR]RewriteCond %{HTTP_REFERER} ^http://.*situslain.com [NC]RewriteRule .* - [F]

Please change the site url in the code above and to add another url please add the command OR after NC with comma (,). And the target website will be blank if it has a reference to its own website.

Usually people call it to grab. Techniques for getting content from people’s websites. And the way to prevent this from happening is not enough if you only use a referrer, you have to need the website’s IP and when you get it let us block it again with the help .htaccess. Here is the code.!

#Blokir IPorder allow,denydeny from 100.000.000.000deny from 10.0.0allow from all#Blokir IP

Please copy the code and edit the numbers 100,000,000,000 with the destination IP. And below it can be added back according to the code above. Actually, this method is quite simple, so you don’t need all of the IP numbers. For example is the destination IP 50.40.30.20, you don’t have to write down all the numbers and just like that 50.40. and all IPs starting with this number will be banned.

Both methods can be practiced directly and if you have any questions about the above, please feel free to comment : Mr. Green:

Hopefully useful and good luck