Last active
August 29, 2015 14:27
-
-
Save zorgsoft/9dd1f7c22580e4b9c1a1 to your computer and use it in GitHub Desktop.
Protection against referral spam for htaccess
This file contains hidden or 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
<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> </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