Apache Web Server Forum

Hi - I've read the source Apache docs, the tutorials here and old threads and I guess I'm just too dumb to get it.

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):

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

The most likely cause of your problem is that the pattern in your rule would also match the replacement image URL, thus causing an 'infinite' loop. To avoid that, and to allow the replacement image to be placed and the mod_rewrie code to work in any directory, simply exclude the replacement image from being rewritten (or redirected, as the case may be): RewriteCond %{REQUEST_URI} !^/psth_to_replacement_imageRewriteRule \.(gif夸pe?g在mp如ng)$ /path_to_replacement_image.$1 [NC]Note also the tweaks to the rule to eliminate unneeded stuff.