I want to redirect google image searches (hotlinked images) directly to my page. My current solution works, but for all referers. I want to make it only for google image search, but I dont know how. Currently I have this (simplified) htaccess code:
RewriteCond %{HTTP_USER_AGENT} !Googlebot-Image [NC]
RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?mydomain.com [NC]
RewriteCond %{REQUEST_FILENAME} .*jpg$ [NC]
RewriteRule (.*) /hotlink.php?p=$1 [L]
This solution works, but I want to make it only for google. I tried
RewriteCond %{HTTP_REFERER} ^http(s)?://(www\.)?google.com [NC]
RewriteCond %{REQUEST_FILENAME} .*jpg$ [NC]
RewriteRule (.*) /hotlink.php?p=$1 [L]
but does not work.
What about this one?