google view image redirect button

2 replies
I have a wallpaper website, when someone search on goole image and click on "view image" button, i redirect the user to dedicated page of this wallpaper using the script bellow. But since i added this script, nobody can hotlink my image on his website. Something i can do to resolve this ?


RewriteCond %{REQUEST_URI} \.(gif|jpg|jpeg|png)$ [NC]
RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?( [NC]
RewriteCond %{HTTP_USER_AGENT} !(googlebot|msnbot|baiduspider|slurp|webcrawler|te oma|photon|facebookexternalhit|pinterest|feedfetch er|photon||akamai|cloudfront|netdna|bitgra vity|maxcdn|edgecast|limelight) [NC]
RewriteRule (.*) redirect.php?to=$1 [L]
#button #google #google image #htaccess #image #php #redirect #view
  • Profile picture of the author coil101
    what site is it i can take a look
    {{ DiscussionBoard.errors[9952603].message }}
  • Profile picture of the author emptee
    Hey mate - the problem is your rewrite rule is catching any link that isn't from your site - this condition is what does that...
    RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?( [NC]

    You could add another condition to match whatever google page you want to redirect for, something like...

    RewriteCond %{HTTP_REFERER} ^http(s)?://(www\.)?google.* [NC]

    Or something.. though you may run into trouble with sites that don't pass the referrer along..

    Another method would be to use some kind of query string to allow hotlinking - eg. ?allowhotlink=true.. or something.. then make sure your condition requires that not to be the case prior to redirecting.

    Hope that all makes sense mate!

    {{ DiscussionBoard.errors[9953936].message }}

Trending Topics