Force a 403 and not a 404 error

To stop image hotlinking (where images on my site can be viewed on their own), I have added the following code to my .htaccess:

RewriteCond %{HTTP_REFERER} !^http://(www\.)? [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?

View Replies:
MrKDilkington replied on at Permalink Reply

You might find this tutorial useful.

"Example 1: How To Prevent Hotlinking"
MJH replied on at Permalink Reply
Thanks for the reply, but that code also returns a 404 in C5, when what I need is a 403. The problem is that SEMRush (and I guess Google too) sees a whole bunch of 404's on my site with this code in place, which is not good for SEO.