How to Block Spam Traffic on Website?


Okay, understood!

Now, after I pasted this code in htaccess my whole site got down… :neutral_face:


The OR is a flag, if you put in the end, it will confuse server and will return Error 500. (Mujhe nahi pata kya ho gya) :rofl:


Any good alternative of Filezilla which shows codes properly for mac?


Good question. Notepad sucks in Win. Now I am hearing similar for Mac too.

May be Sublime you can try… or much better, delete .htaccess and create a new one.


Okay, and if I want to block just one site then I have to use the code like this right?

RewriteCond %{HTTP_REFERER} [NC]
RewriteRule .* – [F]


Yes… yes.


If we want to check this code is working or not then we have to check through Analytics only right?


You can test code easily by blocking fb, Twitter domains for a moment and clicking on shared link.


1- sir spam referral traffic se meri site ko kya kya nuksan ho sakta hai agar main inko block na karu toh?

2- meri site par har roz alag alag domain name se spam traffic aa raha hai … jaise –,, etc. jise mai daily block kar raha hu. to mai aapse ye puchna chahta hu ki kya aise spam traffic ko turant block kar dena chahiye ya fir next day again in domain name se traffic aaye tab block karna chahiye?


If you are using Cloudflare, please stop using .htaccess for blocking referral spam. Having tons of .htaccess rule will affect site performance badly.

Now, there is a better way to handle this problem.

For example, if you want to block specific domain referer traffic. You can implement this way.

Cloudflare > Firewall

Also see: How to Setup Free Cloudflare CDN for Wordpress (Tutorial)?


mujhse kaun si galti ho rahi hai?


@deepaksahu9191 May be Cloudflare issue that time. Were you able to resolve the problem?


cloudflare se block toh kar diya hai maine … ab ye dekhna hai ki spam traffic band hota hai ya nahi.


cloudflare se block karne ke baad bhi se spam traffic aa raha hai. :pensive:


Better, you should create exclude rule in Google analytics. Please search once on Google how to do it.


ok sir


If you are hosting your site on a Linux vps, like Vultr, you can set up iptables to block the spam ips(or the ip segments), you can do it using a SSH terminal like PuTTY or a control panel like VPSrobots. Check this post on How to Set up iptables with VPSrobots.


I’m getting traffic from this garbage now as well.


Apparently, so is everyone on earth. :expressionless:


Me too