homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Home / Forums Index / Google / Google SEO News and Discussion
Forum Library, Charter, Moderators: Robert Charlton & aakk9999 & brotherhood of lan & goodroi

Google SEO News and Discussion Forum

Image search handling of hotlink protection hides images from users

 7:23 pm on Dec 19, 2012 (gmt 0)

If anyone has solved this issue I'd love to hear it.

Typical hotlink protection in htaccess
rewritecond %{HTTP_REFERER} !^$
rewritecond %{HTTP_REFERER} !^http://(www\.)?example\.com [NC]
rewriterule \.(gif|jpe?g|png)$ - [NC,F]

The result: Search engines show a self hosted version of your image instead of your hotlinked image.

The problem: A visitors browser remembers not being allowed to view the image so if they view the site directly at a later date the image remains hidden. This is not a caching issue, if you have properly set browser cache control to cache images then the browser remembers the error.

Condition: This only happens if a visitor clicks on the "Full Sized image" link or the "Website For This Image" link in the sidebar. It does not happen if they click on the x in the corner of the image shown by Google.

If anyone has solved this issue I'd love to hear it. If you'd like to test it remember that you need to clear your cache before visiting Google otherwise your browser will remember the image and show it properly which is not what a new visitor will experience.

Ideas on how to solve this or why it only happens when the visitor clicks the links and not the x beside the image?



 7:57 pm on Dec 19, 2012 (gmt 0)

update: I forgot to mention, the above happens when using X-Frame-Options SAMEORIGIN to block sites from framing your site, which image search also does. The hotlink protection doesn't cause the same issue without the X-Frame-Options being set.

Time to whitelist Google hotlinking or is there another solution that avoids visitors from being blocked on your own site?


 8:16 pm on Dec 19, 2012 (gmt 0)

If anyone has solved this issue I'd love to hear it.

I'm not too sure what you're asking for! This is what I use and it cured all my hotlinking problems meanwhile it still allows Google, Bing and Yahoo access.

RewriteCond %{HTTP_REFERER} .
RewriteCond %{HTTP_REFERER} !^google\.com [NC]
RewriteCond %{HTTP_REFERER} !^bing\.com [NC]
RewriteCond %{HTTP_REFERER} !^yahoo\.com [NC]
RewriteCond %{HTTP_REFERER} !^http://(www\.)?example\.com [NC]
RewriteRule .*\.(gif|jpe?g|png)$ /images/hotlink.gif [L]

One specific image I have went from 30,000 hotlinked requests a day to zero overnight:-)


 9:20 pm on Dec 19, 2012 (gmt 0)

Huskypup, your code whitelists the search engines to hotlink your image. If you use the code you provided, minus the whitelisting, and ALSO have the X-Frame-Options SAMEORIGIN set in headers to prevent your site being framed, then the visitor cannot see the image if they click on Google's "view full size" link or "Website for this image" link(they can if they just click the x in the top right corner of the image, the problem occurs with the links). The visitor's browser(Firefox) apparently picks up the block and their browser cache serves up a broken image even when they are on your site afterwards, unless you do not allow browser caching of images(which you should).

I was *hoping* for a way that still blocks the search engines from hotlinking but without resulting in a visitor browser being unable to see the image even if they visit your site afterwards. Getting rid of the X-Frame-options sameorigin is not an option.

Remember: If you block search from hotlinking they will still show your image but will use their own cache copy instead of your original. That stops hotlinking even more. Let the scrapers hotlink Google's copy of your images if they want... it makes for a much quicker trip out of the serps for the scraper.

I'm looking for this solution because I don't even want the image url on the scraper site, some of my images are being hit by Google's new safesearch approach (off or explicit only, there is no more moderate on .com). Hotlink protection alone wasn't enough to disassociate my image from the content on the scrapers site, just having a non-adult image url on an adult site is apparently enough to cause that image some rating issues.

I hope that better explains the problem. This *feels* like something Google would have to fix on their end.

edit: huskypup, using your code, if you also prevent the framing of your site on other sites using an X-Frame-Options SAMEORIGIN header the visitors who see your images on google.ca (or any other country) will have the problem I'm describing.

Global Options:
 top home search open messages active posts  

Home / Forums Index / Google / Google SEO News and Discussion
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved