Skip to content

Instantly share code, notes, and snippets.

@DanBeckett
Created September 8, 2015 10:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save DanBeckett/5c2c1fe5688f910ac37d to your computer and use it in GitHub Desktop.
Save DanBeckett/5c2c1fe5688f910ac37d to your computer and use it in GitHub Desktop.
Blocking Referral Spam within your .htaccess
# Make sure our server has the rewrite module active.
# (This is very standard - it almost certainly will)
<IfModule mod_rewrite.c>
# Let the system know we’re configuring redirections here
RewriteEngine on
# Now let’s list our redirections (technically these are known as “Rewrite Conditions”.)
RewriteCond %{HTTP_REFERER} ^http://.*referrerurlone\.com/ [NC,OR]
RewriteCond %{HTTP_REFERER} ^http://.*referrerurltwo.\.ru/ [NC,OR]
# We can include as many copies of this line as we need to cover each url.
# The NC flag tells this to be case-insensitive and the OR tells the browser
# to move on to the next rule if this condition isn’t met.
# Bring it all together here - this line tells the browser to forbid access then
# down tools if one of the conditions we listed above is matched.
RewriteRule ^(.*)$ – [F,L]
</IfModule>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment