These files are created to collect and prevent referral spam traffic sources on a server level.
.htaccess is a configuration file for use on web servers running Apache. This file is usually found in the root “public_html” folder of your website. The .htaccess file uses two modules to prevent referral spam, mod_rewrite and mod_setenvif. Decide which method is most suitable with your Apache server configuration. This file is Apache 2.4 ready, where mod_authz_host got deprecated.
With referral-spam.conf
in /etc/nginx
, include it globally from within /etc/nginx/nginx.conf
:
http {
include referral-spam.conf;
}
Add the following to each /etc/nginx/site-available/your-site.conf
that needs protection:
server {
if ($bad_referer) {
return 444;
}
}
NOTE: This method doesn't stop the Google Analytics 'ghost' referral spam (because they are hitting Analytics directly and not even touching your website / server). You should also use filters in Analytics to prevent referral spam.
You can prevent referral spam by:
- Adding a filter
- Enabeling bot and Spider Filtering
- Adding a segment, the best (temporary) solution, there getting more aggressive.
Use the link above or go to your Google Analytics Admin panel and add a Segment.
Filter | Session | Include |
---|---|---|
Hostname | matches regex | ```your-website.com |
Filter | Session | Exclude |
---|---|---|
Source | matches regex | ```semalt.com |
and so on..
If you want to download both files, see the latest zip. Otherwise, if you need to make changes to these files, clone the repo with:
git clone --recursive https://github.com/Stevie-Ray/apache-nginx-referral-spam-blacklist-block.git
If you'd like to help, contribute feedback, or just fork the repository, then add useful stuff and send a pull request.