Site Fuse! programming, design, hosting, promotion and advertising tips for webmasters

.htaccess hotlink protection

Home  \  Forums  \  IT, Hosting & Domain Forums  \  Apache Forums  \  .htaccess hotlink protection
Share   

user photo

Lycan   1 years, 6 months ago

I need some sort of .htaccess rule which will do the following: I have a bunch of images in a folder that are hotlinked on other servers. I want to delete all these images and redirect all these 404's so that instead of the hotlinkers getting a nice red X they`ll get a new image I`ll upload to my server. I know there is a way to do it but I don`t know how. Anyone?
user photo

MrPhear   1 years, 6 months ago

Not sure how much / what sort of traffic you have on that domain, but that could be a waste of valuable non-image 404 traffic. The following code will redirect image "404s" to a default image, normal "document" 404s will be treated "normally".

RewriteEngine on
RewriteCond %{REQUEST_URI} !-U
RewriteRule \.(gif|jpg|jpeg)$ /your_path_to/new.gif [L]
# the following is for normal 404s
ErrorDocument 404 http://www.your404.com
user photo
Guest