[. Htaccess] Block a website referrer (Block referrer)

It happens that links to your site appear on sites that are not yours and you are not content. Can be spam sites, Adult sites or… simply sites from which not wish to receive visitors.

To block visitors coming from these sites, you need to add a few lines .htaccess.

# definiti variabila spam_ref
SetEnvIfNoCase Referer "^http://(www.)?site-refferer.com" spam_ref=1
SetEnvIfNoCase Referer "^http://(www.)?alt-site.com" spam_ref=1
SetEnvIfNoCase Referer "^cuvant-inclus-in-adresa-url" spam_ref=1
# blocheaza tot ce este setat in spam_ref
<FilesMatch "(.*)">
Order Allow,Deny
Allow from all
Deny from env=spam_ref
</FilesMatch>

"#”Added in front of a line in .htaccess, cancels that line. Let's say it's an informative line.

SetEnvIfNoCase Referer "^cuvant-inclus-in-adresa-url" spam_ref=1

This line blocks all sites containing the URL, set your word, for example:

SetEnvIfNoCase Referer "^adult" spam_ref=1

The line above will block all sites that contain referrer "adult"In the URL. adult123.com, adult.ro, 210391adult.net.

Passionate about technology, I enjoy writing on StealthSettings.com since 2006. I have a rich experience in operating systems: macOS, Windows, and Linux, as well as in programming languages and blogging platforms (WordPress) and for online stores (WooCommerce, Magento, PrestaShop).

Leave a Comment