This is where things will get a little technical because we are going to access and edit your htaccess file via FTP.
If you are using a WA hosted site you should be able to follow along here and see results.
I also need to disclaim that I am not an expert in IT and if you have very technical questions about editing your htaccess file, I may not be able answer them as I have limited experience outside of this process.
The first thing we need to do is access the htaccess file via FTP. This file will allow us to block specific referral sites and prevent spam.
IMPORTANT:Before you edit this file, you should save a backup copy.
1. Log into your site via FTP (I use Filezilla)
2. Open your httpdocs folder on the WA server
3. Go to your htaccess file
4. Right click And choose Download (just to save a backup copy)
5. Right click the file again and choose View/Edit
This will open up you htaccess file for editing. It will open as text file.
Here you will add code that is going to tell your site how you would like it to handle referral spam.
Below I will show you how to block traffic from:
- One URL (websitename.com)
- A URL with a sub domain (i.e. subdomain.website.com)
- Multiple URL’s at one time
Choose one of the options below and paste the code into your htaccess file.
It can go anywhere in the file as long as it is not in between an OPEN <if module>. You can see my htaccess file at the bottom
Block Traffic From A Standard URL
In this example i will block traffic from 1 standard URL (websitename.com).
Put the following code in your htaccess file and replace websitename.com with whatever standard URL you want to block:
# block referrer spam RewriteEngine On RewriteCond %{HTTP_REFERER} websitename\.com [NC] RewriteRule .* – [F,L]
The code above tells the server to block all traffic from websitename.com.
The[NC] flag tells the server that the website URL is not case sensitive. In the rewrite rule [F,L], the F tells the server to return a “403 forbidden error” and then the L tells it to stop processing.
Block Traffic From A Sub Domain URL
In this example I will block traffic from a sub domain URL (fourum5674.websitename.com)
Put the following code in your htaccess file and replace websitename.com with whatever sub domain URL you want to block:
# block referrer spam RewriteEngine On RewriteCond %{HTTP_REFERER} ^http://.*websitename\.com [NC] RewriteRule .* – [F,L]
The code above tells the server to block all traffic from ANY sub domain from websitename.com.
Now we can combine these codes and block multiple spam referral URL's.
Block Traffic From Multiple URL's
In this example we will block several spam referral URL's. To do this we use the OR flag.
The example below is my exact htaccess coding you can copy. You just may need to add more sites in for which ever ones are spamming you.
# block referrer spam RewriteEngine On RewriteCond %{HTTP_REFERER} buttons-for-website\.com [NC,OR] RewriteCond %{HTTP_REFERER} ^http://.*simple-share-buttons\.com [NC,OR] RewriteCond %{HTTP_REFERER} simple-share-buttons\.com [NC,OR] RewriteCond %{HTTP_REFERER} 7makemoneyonline\.com [NC,OR] RewriteCond %{HTTP_REFERER} darodar\.com [NC,OR] RewriteCond %{HTTP_REFERER} semalt\.com/ [NC] RewriteRule .* – [F,L]
If you are wondering why I have simple-share-buttons.com listed twice, it’s because I receive spam from both a standard URL and a sub domain. I am not sure if there is a better way to do that, but for me it stopped all referral spam from the site.
Also notice that the last block on Semalt.com only says [NC] after it and does not contain OR, that is because it is the last site in my list.
After you have edited your htaccess file, you need to click save and let it rewrite on the server via FTP.
Save the text file and then close it
The server will know the file has changed: Choose YES to upload
That's it! You should know see your referral spam stop for the sites you have listed.
See My Htaccess file Example
This is a picture if EXACTLY how my code sits inside of my htaccess file. Notice it is NOT in between any <if module> </if module> code.