Skip to content

Instantly share code, notes, and snippets.

@zorgsoft
Last active August 29, 2015 14:27
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 zorgsoft/9dd1f7c22580e4b9c1a1 to your computer and use it in GitHub Desktop.
Save zorgsoft/9dd1f7c22580e4b9c1a1 to your computer and use it in GitHub Desktop.
Protection against referral spam for htaccess
<form>
<table style="width: 100%;">
<tr>
<td style="width: 200px;">Ссылки спамеров<br><small>(можно много, но 1 ссылка в 1й строке, без http и www)</small></td>
<td><textarea name="urlList" id="urlList" style="width: 100%; height: 150px;"></textarea></td>
</tr>
<tr>
<td>&nbsp;</td>
<td><input type="button" name="start" id="start" value="Создать" calss="btn btn-primary" onclick="cStart();"></td>
</tr>
<tr>
<td>Результат:<small><br>(результат вставляь в конец файла .htacces на сайте который надо защетить)</small><br></td>
<td><textarea name="htaccessText" id="htaccessText" style="width: 100%; height: 150px;"></textarea></td>
</tr>
</table>
</form>
<script type="text/javascript">
function cStart(){
var arrayOfLines = document.getElementById('urlList').value.split("\n");
var arrayOfNewLines = [];
arrayOfLines.forEach(function(item, i, arrayOfLines){
if(item.replace(/\s/g,"") != ""){
arrayOfNewLines.push(
'RewriteCond %{HTTP_REFERER} ^http(s)?://(www\.)?'+item+'.*$ [NC]',
'RewriteRule .* http://'+item+' [L]',
' '
);
}
});
document.getElementById('htaccessText').value = arrayOfNewLines.join("\n");
}
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment