Evitare l'hotlinking di immagini o files con Apache
Jump to navigation
Jump to search
- Assicurarsi che la location abbia impostato (nel virtuahost):
<Directory /var/www/rvmgroup.it/people/html/gabriele.vivinetto/wordpress>
AllowOverride All
</Directory>
- Creare nella root del sito un file .htaccess:
# Questo serve rper forza !!! Se non si ha l'AllowOverride All, si ottiene un errore
Options +FollowSymlinks
<IfModule mod_rewrite.c>
# attiva mod_rewrite
RewriteEngine On
# BEGIN Hotlink Protection
# Modo 1, lassa perde ...
#RewriteCond %{HTTP_REFERER} !^$
#RewriteCond %{HTTP_REFERER} !sharp\.blogdns\.net [NC]
#RewriteCond %{HTTP_REFERER} !google\. [NC]
#RewriteRule .*\.(jpe?g|gif|png|bmp|zip|cab|deb|gz|bz|bz2|tar)$ /wp-content/uploads/no-hotlink.image [NC,L]
#
# Modo 2
# Se la richiesta non proviene dal mio sito
RewriteCond %{HTTP_REFERER} !^http://sharp.blogdns.net/.*$ [NC]
# O se la richietsa non proviene dalla mia homepage
RewriteCond %{HTTP_REFERER} !^http://sharp.blogdns.net$ [NC]
# O se l'url richiesto non contiene questa stringa (utile per script di download)
RewriteCond %{REQUEST_URI} !/phpmv2/ [NC]
# Scegliere una di queste due possibilita'
# Restituisce forbidden
# Allora per tutti gli url che finiscono con quete estensioni, dai un Forbidden
#RewriteRule \.(jpe?g|gif|png|bmp|zip|cab|deb|gz|bz|bz2|tar)$ - [F]
# Redireziona a immagine divieto
# Allora per tutti gli url che finiscono con quete estensioni, mostra l'immagine seguente.
# Attenzione, l'immagine è volutamente con estensione jpe, riconosciuta come imamgine, ma non inclusa nell'elenco
RewriteRule .*\.(jpe?g|gif|png|bmp|zip|cab|deb|gz|bz|bz2|tar)$ /wp-content/uploads/no-hotlink.jpe [NC,L]
# END Hotlink Protection
</IfModule>
RIferimenti
- .htaccess tricks and tips.. part two: url rewriting with mod rewrite.
- WordPress › Support » Stop Hotlinking via Wordpress?:
- Stop Hotlinking with htaccess. Test your Image Hotlink Protection with our Hotlink Checker from altlab.com.
- Htaccess per l’anti-hotlink con Wordpress / Melodycode.com - Life is a flash