.htaccess to block hotlinked image (blocking on my own site)

72 Views Asked by At

I am attempting to block hotlinked images from a specific site and re-route to an externally loaded/hosted image somewhere else.

I made some edits to my .htaccess file

Buy it also seems to block my OWN site/domain from my own images.. (even though I believe I am allowing it?)

I cant seem to get things to work with JUST blocking the external site...(without blocking my own site from my own images?)

I've tried so many lines... I cant make heads or tails on what is the issue that is blocking images from my own site.

Here is is my latest attempt

RewriteEngine On
#RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://myfakesite.net.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http://www.myfakesite.net.*$ [NC] 
RewriteCond %{HTTP_REFERER} ^http://(www\.)?external-site\.com(/.*)*$ [NC,OR]
RewriteCond %{HTTP_REFERER} ^https://(www\.)?external-site\.com(/.*)*$ [NC,OR]
RewriteRule .*\.(gif|jpg|jpeg|bmp|png)$ https://path-to-externally-hosted-image.jpg [R,NC] 

*I erroneously though this would be much easier.. LOL

How can I block external-site.com and allow everything from mysite.net?

0

There are 0 best solutions below