Blocking Spam Referrals via .HTAccess
Okay, before you considering even touching this important file, please back it up!!!
And, perhaps the beginners would like to know what this file is all about (perhaps you're reading this for future reference - see my note above.)
What is the .HTAccess file?
The .htaccess is a distributed configuration file, and is how Apache (the servers) handles configuration changes on a per-directory basis. WordPress uses this file to manipulate how Apache serves up the website files from its root directory, and subdirectories. Most notably, WordPress modifies this file to be able to handle the more friendly permalinks.
As I mentioned before, filtering out the data in Google Analytics will help provide more accurate results.
But, the .HTAccess file is the key to stopping the spam before it has a chance to leave a digital footprint or even register anywhere on your website.
You can access your .HTAccess file via two means for the most part.
If you're familiar with FTP, you can download the file from the server, edit it and re-upload. I've done this several times and it's not a big deal. But, nowadays I prefer the easier method. (Well, I guess that's a matter of opinion. It's like using a remote control for the T.V. - if the remote is across the room. Do I get up and change the channel or get the remote instead and then change the channel?)
Regardless, here is what the most basic .HTAccess file might look like:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
Notice the first line and the very last line have the "#" symbol. Yep, you guessed it, these are the markers for the beginning and end. All commands and syntax need to be between these two lines or they don't get read by the system.
Then, we have an IF question. IF this happens, DO something.
This is followed by the ReWriteEngine -- basically this line says, hey turn the key and crank up the ReWrite Engine..... I'm about to ask it to do something.
Then, we have Rules and Conditions.
That's really all you need to know about the basic file.
NOTE: - Again, copy and paste your .HTAccess file and keep it safe. Don't ever edit this file without knowing how to take out your changes and put it back into place. This can totally wreck your website and make it unusable if you do this wrong. Trust me here!
Cheers
Darwyn