I've read many tutorials on blocking hotlinking of images and trying to get it to work on my site. This is my htaccess file in the root directory: RewriteEngine on RewriteRule ^[^:]*\.(php|src|jpg|jpeg|png|gif|bmp|css|js|inc|phtml|pl|ico|html|shtml)$ - [L,NC] RewriteRule ^index.php?title - [L] RewriteRule ^(.*)\&(.*)$ $1\%26$2 RewriteRule ^(.+)$ /index.php?title=$1 [L,QSA] RewriteEngine on RewriteCond %{HTTP_REFERER} !^$ RewriteCond %{HTTP_REFERER} !^https?://(www\.)?mywebsite\.com($|/) [NC] RewriteCond %{HTTP_REFERER} !^https?://(www\.)?myotherwebsite\.com($|/) [NC] RewriteRule \.(gif|jpg|jpeg|png|mp3|mpg|avi|mov)$ - [F,NC] Code (markup): I also have placed this in my images folder: RewriteEngine on RewriteCond %{HTTP_REFERER} !^$ RewriteCond %{HTTP_REFERER} !^https?://(www\.)?mywebsite\.com($|/) [NC] RewriteCond %{HTTP_REFERER} !^https?://(www\.)?myotherwebsite\.com($|/) [NC] RewriteRule \.(gif|jpg|jpeg|png|mp3|mpg|avi|mov)$ - [F,NC] Code (markup): Whether I use the httaccess file in my image directory or whether I place the code to block hotlinking in my root directory and image directory my site still allows hotlinking. Could someone offer help on getting this to work? I think I'm really close but just missing something.
What's the point of this line? RewriteRule ^[^:]*\.(php|src|jpg|jpeg|png|gif|bmp|css|js|inc|phtml|pl|ico|html|shtml)$ - [L,NC] This maybe blocking the next rewrite rule on the images. Cheers,
I believe it allows short urls for those types of files and I think you are correct. I tried to take out that line completely and all images on article pages (my site is wiki with thousands of pages) showed up blank. So taking it out is not an option. I am stumped.
Btw ... problem is solved. It turns out the file was working but my browser's cache made it seem like hotlinking was still allowed. When I doubled checked after clearing my browser ... images are not shown when hotlinked.
ALWAYS! clean yor browser chache after making any sort of server changes .. or just turn off browser chache ..