Created
October 19, 2015 20:13
-
-
Save stackcoder/e2ac967c40e4bd30c57b to your computer and use it in GitHub Desktop.
Generates a .htaccess file to block referer spam based on https://github.com/piwik/referrer-spam-blacklist.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# wget https://raw.githubusercontent.com/piwik/referrer-spam-blacklist/master/spammers.txt -O spammers.txt | |
{ | |
echo -ne 'RewriteEngine On\n\n' && \ | |
echo '# denied referers' && \ | |
cat spammers.txt | head -n -1 | sed 's/\./\\\./g' | sed 's/^\(.*\)$/RewriteCond "%{HTTP_REFERER}" "\1$" [NC,OR]/' && \ | |
cat spammers.txt | tail -n 1 | sed 's/\./\\\./g' | sed 's/^\(.*\)$/RewriteCond "%{HTTP_REFERER}" "\1$" [NC]/' && \ | |
echo 'RewriteRule .* - [F]' | |
} > referer.htaccess |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment