QUOTE (WhiteShepherd)
It's just not working. Is my syntax correct or am I doing this wrong?
RewriteRule .*.jpg$ - [L] won't work because there is nothing to rewrite.
The dash (
- ) means there is no file or URL to substitute
The
L flag is the last rule so you are substituting
.*.jpg$ with nothing.
You can replace
L with the
F flag to produce a 403 error or you change the dash to a URL and use the
L flag with the
R redirect flag. Note you can only send another image to the hotlinking site, however, IMHO, it is best to send a 403 error.
Also it is a good idea to use
NC not case sensitve flag.
Examples:
RewriteRule .*.jpg$ /bandwidth-thief.jpg [NC,L,R]
RewriteRule .*.gif$
http://domain.tld/thief.gif [NC,L,R]
RewriteRule .*.jpg$ - [F,NC]
I use the following to produces a 403 error. Domain names and image extensions can be any case. For example JPG, jpg, Jpg gIF PnG
RewriteEngine on
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://(www.)?mydomain.tld [NC]
RewriteRule (.*).(gif|jpg|png)$ - [F,NC]
For SSL sites you will need a RewriteCond for https as well
RewriteCond %{HTTP_REFERER} !^https://(www.)?mydomain.tld [NC]
<added by Doodle>
I forgot to include info about the
R flag The examples have been edited to reflect the correct syntax for redirecting to another file