I'm trying to create HTACCESS Hotlink Protection on my site but I'd like all Google top level domains (.com., .co.in, .co.uk, etc) to be able to access my files, so that visitors to the Google AMP version of my pages can view linked images and resources.
I tried the following in my htaccess but it's blocking Google AMP users
RewriteEngine on
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !.*google.* [NC]
RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?patchworkoftips.com [NC]
RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?feeds.feedburner.com [NC]
RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?feeds2.feedburner.com [NC]
RewriteRule \.(jpg|jpeg|gif|png|bmp|iso|zip|mp4|exe|xlsx|img|rar|apk|bar|7z|ipd)$ https://i.ibb.co/2hcQgZw/stop-hotlinking-images.jpg [NC,R,L]
For example, the URL for my Google AMP page starts with www.google.com.ng/amp/s/ and when users of such pages click to download a file they get an error image.
Anybody accessing the site directly from the main domain www.patchworkoftips.com can easily download the file.
I added RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?google.com.ng [NC]
but it doesn't seem to work either for some reason
I saw someone mention RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?google\.*$/.*$
but someone replied that this would give access to sites like "googlefake.com", "google123.es"
So the question here is how can I enable file download access for users landing on the Google AMP pages on my site and what would be the best way to achieve this for all google TLDs without clogging the htaccess file.
.htaccess
code. The code you've posted is simply a "condition" - which doesn't do anything by itself.