I've been running into the problem of different people remote linking images from my site and I'd like to inhibit that, but if possible, to inhibit all but the images or files that I remote link myself. See, I have an mp3 I use from my server for my journal's background music and I'd like for that to stay that way since I don't know any place that will let you remote link from their servers either paid for or free. But anyway, I know I need an HTACCESS file for that but I don't know how to make them. Is there anyone here that could help me?
If you have problems, I can post my image protection htaccess file when I get home.
__________________
If this post contains any code, I may or may not have tested it. It's probably just example code, so no getting knickers in a bunch over a typo, OK? If it doesn't have basic error checking in it, such as object detection or checking if objects are null before using them, put that in there. I'm giving examples, not typing up your whole app for you. You run code at your own risk.
Bored? Visit http://www.kaelisspace.com/
I'm pretty sure that my server is Apache, because I have another HTACCESS file utilized for SHTML includes and such. And if you don't mind giving me yours that'll be great
You can't have two in the same directory.
But here's mine from awhile ago. Change the referer in there to your domain. Put in folders with images, but NOT your main directory (an images subfolder, for example).
If this post contains any code, I may or may not have tested it. It's probably just example code, so no getting knickers in a bunch over a typo, OK? If it doesn't have basic error checking in it, such as object detection or checking if objects are null before using them, put that in there. I'm giving examples, not typing up your whole app for you. You run code at your own risk.
Bored? Visit http://www.kaelisspace.com/
Ok, just to be clear, I CAN use two separate .htaccess files, but just not in the same directory? I know the sort of damage they can do if there's even one mistake made.
Yes, exactly.
You can have one htaccess file per directory, as far as I know.
I would imagine the server would have problems with two in the same directory, but I haven't tested that idea.
Maybe it just grabs the first one, maybe it tries to combine the rules. Maybe it blows up.
If I were really curious about how it would handle two in the same directory, I'd look up the Apache docs on that. But I have yet to think I needed that, so I didn't. *grins*
__________________
If this post contains any code, I may or may not have tested it. It's probably just example code, so no getting knickers in a bunch over a typo, OK? If it doesn't have basic error checking in it, such as object detection or checking if objects are null before using them, put that in there. I'm giving examples, not typing up your whole app for you. You run code at your own risk.
Bored? Visit http://www.kaelisspace.com/
Since you can put all your stuff in one .htaccess there's never a need for two of them in the same directory, is there? And obviously - uploading the second one would simply overwrite the first.
You can add the code above to your existing .htaccess, but you have to allow hotlinking for the 'hotlink' image, so I added a condition:
And obviously - uploading the second one would simply overwrite the first.
/me smacks self in head.
*sigh*
__________________
If this post contains any code, I may or may not have tested it. It's probably just example code, so no getting knickers in a bunch over a typo, OK? If it doesn't have basic error checking in it, such as object detection or checking if objects are null before using them, put that in there. I'm giving examples, not typing up your whole app for you. You run code at your own risk.
Bored? Visit http://www.kaelisspace.com/
My host told me that I should be able to access my .htaccess file but I can't see it, so I don't know how I'm going to make the changes to it. Not to mention doing something wrong and bringing the entire site down. So much for stopping the hotlinking. Doesn't matter, I'll be shutting down next year
Description:
Assume we have under http://www.quux-corp.de/~quux/ some pages with inlined GIF graphics. These graphics are nice, so others directly incorporate them via hyperlinks to their pages. We don't like this practice because it adds useless traffic to our server. Solution:
While we cannot 100% protect the images from inclusion, we can at least restrict the cases where the browser sends a HTTP Referer header.
Hi. I've tried several versions of this code. Nothing works. Most recently I've tried the one above from Span since it seems to be the most recent. Still doesn't work.
My assumption being that the code can be inserted in the root directory to work, even though images being hotlinked are in sub-folders.
No slash in front of "hotlinkedtheft\.gif". My mistake. Not needed in .htaccess, but that can't be the real problem.
Now, your ErrorDocument lines. For some reason (plain blindness, maybe..) I didn't see you used absolute URLs in there. Actually that is not supposed to work at all.. only relative URLs should be there. Relative to the root of your domain. In your case, a slash.
ErrorDocument 404 /
ErrorDocument 403 /
You could try that. But.. using your index page as a 404 is not an 'allsmart' thing to do. Search engines like Google, Yahoo and MSN might see your 404 pages as duplicate content, resulting in ranking much lower. Better make a separate page for your 404s.