.htaccess hotlink protection having no effect?

# prevent hotlinking
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?thenerdystudent.com [NC]
RewriteCond %{HTTP_REFERER}  !^https://([^.]+\.)?google\. [NC]
RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?facebook.com [NC]
RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?twitter.com [NC]
RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?reddit.com [NC]
RewriteRule \.(jpg|jpeg|png|gif)$ – [NC,F,L]

Is this because the image is being served from the Cloudflare cache, or an error on my part?

Thanks!

Once an image is in Cloudflare’s hands, CF won’t go back to your site to request for it again, so the htaccess rules would only apply when the CF cache expires.

Of course if Cloudflare is serving the image from its cache, hotlink protection is not as important, as it won’t consume your server CPU, bandwidth etc.

If you still want to enable hotlink protection, you can enable it on the Dashboard > Scrape Shield app. Alternatively, you can create a Firewall Rule to block such requests.

2 Likes

I saw that however it would block google which I don’t want. I’ll leave it like this as it won’t impact my bandwidth.

Thanks!

2 Likes