Mobile app version of vmapp.org
Login or Join
Hamaas447

: Is there a way to disable image hotlinking by 3rd-party sites while allowing Google Image Search Can I block other sites from hotlinking to images on my server to preserver bandwidth while still

@Hamaas447

Posted in: #Bandwidth #Bing #GoogleImageSearch #Hotlinking

Can I block other sites from hotlinking to images on my server to preserver bandwidth while still allowing my site to stay discoverable in Google and Bing image search?

10.01% popularity Vote Up Vote Down


Login to follow query

More posts by @Hamaas447

1 Comments

Sorted by latest first Latest Oldest Best

 

@Alves908

I am assuming Apache and .htaccess.

From: perishablepress.com/creating-the-ultimate-htaccess-anti-hotlinking-strategy/
RewriteEngine on
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{REQUEST_FILENAME} -f
RewriteCond %{REQUEST_FILENAME} .(gif|jpe?g?|png)$ [NC]
RewriteCond %{HTTP_REFERER} !^https?://([^.]+.)?domain. [NC]
RewriteCond %{HTTP_REFERER} !^https?://([^.]+.)?google. [NC]
RewriteCond %{HTTP_REFERER} !^http?://([^.]+.)?google. [NC]
RewriteCond %{HTTP_REFERER} !^https?://([^.]+.)?bing. [NC]
RewriteCond %{HTTP_REFERER} !^http?://([^.]+.)?bing. [NC]
RewriteRule .(gif|jpe?g?|png)$ - [F,NC,L]


You will need to change domain in the HTTP_REFERER line to your domain name of course. You may also want to change https to http as well. Also, you can add and or delete file extensions. They do not all have to be images.

This is a trusted site for .htaccess examples should you ever need one.

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme