Protéger son site contre le hotlinking via fichier htaccess

Protégez votre site contre le hotlinking et les pompeurs de contenu avec quelques directives .htaccess pour Apache.

De manière globale en retournant un accès interdit

SetEnvIfNoCase Referer "^http://notes.depad.fr/" local_ref=1
Order Allow,Deny
Allow from env=local_ref

Ou de manière plus subtile en y mettant plusieurs conditions

RewriteEngine on
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://(www.)?notes.depad.fr(/)?.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http://(www.)?google.(fr|de|com|ca)(/)?.*$ [NC]
RewriteRule .*.(gif|png|jpg|jpeg|pdf|doc|wav|bmp|avi|mpg|mpeg|mp3|zip|rar)$ /nohotlink.png [R,NC]

Si vous avez mis en place un cache Varnish en amont, consulter cet article : Protection contre le hotlinking avec Varnish

Catégories : Linux 
Tags: Apache Astuce 

Suggestions de lecture :