Question Asked: How Do I Stop People From Linking To My Images On My Website?
|
May 1st, 2009 |
It’s actually pretty simple to do, believe it or not.
The process you’re referring to, is called “hot linking”, and it’s a form of them. For those of you that’re wondering what that means, or why you should care, read on.
Hotlinking is when someone links directly to an image on your website, on their’s. That means that the image they’re showing on their site, is being served from your server, effectively stealing your bandwidth, which you pay for.
To stop that, you need two things:
- A lightweight image to show instead of the image they’re linking to.
- An .htaccess file.
Assuming you’ve already got the second, make a quick image for the first. What I like to do, is use spacer.gif, a 1×1 pixel with no content. That way when they try to preview their page with the hotlinked image, they’ll think their code is wrong, and spend quite a while trying to fix it.
Once you’ve got your image, you need to edit your .htaccess file. Just drop this code in anywhere.
RewriteEngine on
RewriteCond %{HTTP_REFERER} .
RewriteCond %{HTTP_REFERER} !^http://(www\\.)?yoursite\\.com [NC]
RewriteRule \\.(gif|jpe?g)$ /images/hotlink.$1 [L]
Just replace yoursite with your domain name, and .com with whatever your extension is (.com, .net, .org, etc.)
Then, replace /images/hotlink with the location to your image you created for number 1, above. In my case, it’d be images/spacer. RewriteRule \\.(gif|jpe?g) automatically adds either .jpg or .gif to the end of it, depending on which file exists.
If you want to allow hotlinking from other sites, like Google Cache, for example, just add another line to it, allowing that domain, like so:
RewriteCond %{HTTP_REFERER} !^http://(www\\.)?google\\.com [NC]
That allows Google.com to show your imagse, without showing the hotlink protection image. Simple, right?
Other answers you may find useful:
- How Do I Redirect All My Webpages To My New Domain Name?
- How Do I Change My Google Apps E-mail URL?
- How Do I Move My WordPress Blog To A New Domain?
- How Do I Setup Email Subscriptions in FeedBurner for WordPress?
- Can I Copyright My Website?
Previous Post |
Next Post |
| « Why Is There No Light In My Freezer? | How Can I Find Out Sports Scores On My iPhone? » |
Comment On This Post
