Force a 403 and not a 404 error
Permalink
To stop image hotlinking (where images on my site can be viewed on their own), I have added the following code to my .htaccess:
This works, however it forces a 404 page for every image when what I really want is to serve a 403 page forbidden. I have thousands of images on my site and for SEO reasons I don't want a whole load of 404 pages.
Does anyone know how I could do this?
RewriteCond %{HTTP_REFERER} !^http://(www\.)?mydomain.com/ [NC] RewriteRule \.(jpe?g|gif|bmp|png)$ - [F,NC,L]
This works, however it forces a 404 page for every image when what I really want is to serve a 403 page forbidden. I have thousands of images on my site and for SEO reasons I don't want a whole load of 404 pages.
Does anyone know how I could do this?
You might find this tutorial useful.
"Example 1: How To Prevent Hotlinking"
https://www.digitalocean.com/community/tutorials/how-to-set-up-mod_r...