since long i have ten thousands/m hot linked image requests from myspace, hi5, etc. normal hotlinked images are successfully replaced by a replacement banner. however I also have large numbers of hotlink attempts where the remote site uses a broken URL - most likely a copy/paste error by hotlinker OR URL-size limit by remote host. such hotlink attempts with broken URLs always lead to a server error (404) I would like my banner still be shown - to avoid apache error as well as to make hotlinker aware of his error. here an example of how such a broken partial URL from a hotlinker may look: /wallpapers/widescreen_wallpapers/beautiful_roses/widesc hence part of subsolder/filename PLUS file extension are missing is there a way to rewrite such broken file requests WITHOUT damage to real full file requests by regular surfers coming from such referrer URLs ?? in the same path as the hotlink request there also are regular HTML files that still should be served correctly !!
thanks nintendo it works like a charm - just like my mod_rewrite for full uRLs ... i was thinking complex mod_rewrite, yet your solution seems the easy perfect one
Of course, that will mean that every 404 on your site will cause that image to be shown... and if it's not an image, then the hotlinkers will just get a broken image, not your banner. You could try with something like this: RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-l RewriteCond %{HTTP_REFERER} !www.yoursite.com RewriteCond %{HTTP_REFERER} !^$ RewriteRule ^.*$ /images/banner.png [L] Code (markup): What it all means is if what they requested is not a file (-f), a directory (-d) or a link (-l) and the referrer is not your site or empty, then send them your banner instead of the normal 404 page. You could add extra RewriteCond directives, such as: RewriteCond %{REQUEST_URI} /images Code (markup): Which would make all of the above only apply if the file they requested was in the images directory.
the hotlinking problem occurs only in a particular subfolder hence of course i have placed that a.m. code ONLY in the htaccess of that subfolder all the rest of the site is hotlink protected by regular mod_rewrite with banner replacement. as already published above - all works perfectly now with nintendo's solution. however I keep your solution on file for possible later usage where needed.