Forum Moderators: phranque
While preventing hotlinking to my images, I want to allow only Google to access the files on the server.
The important thing is that there are several different types of entries in the log file like:
images.google.com/imgres
google.co.uk/imgres
images.google.de/imgres
So I think a rule to allow:
1. Any subdomains or www before .google.
i.e. [google.xx...]
or [images.google.xx...]
2. And any TLD after .google.
i.e. .google.co.uk/imgres
or .google.co.uk/search
will be fine.. allowing other directories like "search" will not be important, that's no problem.
I have found this:
!^http://[^/.]\.google.*$ [NC]
but I may be completely wrong, so I will be pleased to hear your comments..
Current .htaccess is something like this:
RewriteEngine on
RewriteCond %{HTTP_REFERER}!^$
RewriteCond %{HTTP_REFERER}!^http://www.mysite.com.*$ [NC]
RewriteCond %{HTTP_REFERER}!^http://mysite.com.*$ [NC]
RewriteCond %{HTTP_REFERER}!^http://my.ip.xx.xx.*$ [NC]
RewriteRule .*[Jj][Pp][Gg]$¦.*[Gg][Ii][Ff]$¦.*[Zz][Ii][Pp]$¦.*[Pp][Nn][Gg]$ [mysite.com...] [R,L]
RewriteEngine on
RewriteCond %{HTTP_REFERER} .
RewriteCond %{HTTP_REFERER} !^http://(www\.)?mysite\.com [NC]
RewriteCond %{HTTP_REFERER} !^http://my\.ip\.123\.45 [NC]
RewriteCond %{HTTP_REFERER} !^http://.*google\.(com¦(co\.)?[a-z]{2})/(imgres¦search) [NC]
RewriteRule \.(jpg¦gif¦zip¦png)$ /myfile.jpe [NC,L]
I have changed the code with yours, and no errors, it's working great.
I just don't have ability to test the:
RewriteCond %{HTTP_REFERER}!^http://.*google\.(com¦(co\.)?[a-z]{2})/(imgres¦search) [NC]
tag. I think I understood the part after .google.
Just one question: Does .* before google mean "include all subdomains"? Because, it is important to include:
images.google.com....
for example, in the expression.
thank you..