Forum Moderators: phranque
I block hot linked images but so many people are too stupid to understand the hotlinked image is not displaying my server kicks 403 after 403 day after day. I want to try the strategy of sending the embedded image request to a new image with notice of the hotlink and our domain. And I can not for the life of me get it to work.
Here is what I've had and tried:
Original (worked - kicked 403s)
RewriteRule .*\.(gif夸pg夸peg在mp如ng)$ - [F,NC] New - not working - kicking 400s (w/o broken pipes of course)
RewriteRule .*\.(gif夸pg夸peg在mp如ng)$ /images/stolenpicture.jpg [NC,L] In one thread here I saw a note about blocking your redirect with your own rule so I tried to be sure I was not blocking myself with above rule but I still kicked 400 errors (just blocked jpgs and sent to gif):
RewriteRule \.(jpg)$ /images/stolenpicture.gif [NC] Short version of full original code in .htaccess
Options +FollowSymlinks
RewriteEngine on
RewriteCond %{HTTP_REFERER}!^$
RewriteCond %{HTTP_REFERER}!^http://(www\.)?mydomain.com(/)?.*$ [NC]
RewriteCond %{HTTP_REFERER}!^http://(www\.)?google.com(/)?.*$ [NC]
RewriteRule .*\.(gif夸pg夸peg在mp如ng)$ - [F,NC] Again, this is the original and it worked. I replaced last line with redirect to stolen pic and I get 400 errors.
This is on a Mambo site and after these rules run another set continue for SEF URLS:
RewriteCond %{REQUEST_FILENAME}!-f
RewriteCond %{REQUEST_FILENAME}!-d
RewriteRule ^(.*) index.php Are these breaking the image redirect?
Thanks!
Well, not sure I know why, but I've got this working and will share my solution. I'm now using:
RewriteRule .*\.(gif夸pg夸peg在mp如ng)$ stolenpicture.$1 [NC] as the last line and this rule seems to work just fine.
If you are going to lift this for your own use make sure you replace the broken pipes with solid pipes (above the "\" key on your keyboard)!
stolenpicture = file name of sub'd image.
It is now in my root (was it a path problem all along?)
Nobody steals my non-gif or jpg files, so I've got a stolenpicture.gif and stolenpicture.jpg sitting in the root. The stolenpicture.$1 looks to source type and replaces it with the same type. So amazingpicture.jpg gets redirected to stolenpicture.jpg
Am I understanding this much correctly?
It does appear to work at least - even if my brain does not.
RewriteCond %{REQUEST_URI} !^/psth_to_replacement_image
RewriteRule \.(gif夸pe?g在mp如ng)$ /path_to_replacement_image.$1 [NC]
Jim