<body><script type="text/javascript"> function setAttributeOnload(object, attribute, val) { if(window.addEventListener) { window.addEventListener('load', function(){ object[attribute] = val; }, false); } else { window.attachEvent('onload', function(){ object[attribute] = val; }); } } </script> <div id="navbar-iframe-container"></div> <script type="text/javascript" src="https://apis.google.com/js/plusone.js"></script> <script type="text/javascript"> gapi.load("gapi.iframes:gapi.iframes.style.bubble", function() { if (gapi.iframes && gapi.iframes.getContext) { gapi.iframes.getContext().openChild({ url: 'https://www.blogger.com/navbar.g?targetBlogID\x3d29653863\x26blogName\x3dPro-SEO\x26publishMode\x3dPUBLISH_MODE_BLOGSPOT\x26navbarType\x3dSILVER\x26layoutType\x3dCLASSIC\x26searchRoot\x3dhttp://pro-seo.blogspot.com/search\x26blogLocale\x3den_US\x26v\x3d2\x26homepageUrl\x3dhttp://pro-seo.blogspot.com/\x26vt\x3d2468949507327226682', where: document.getElementById("navbar-iframe-container"), id: "navbar-iframe" }); } }); </script>
« Pro-SEO Home || When Is The Next PR (page rank) Update? » || How To Get Backlinks » || Adsense Banned me -- What should i do? » || Google Adsense Alternatives » || Google Adsense - Cost Per Action (CPA) » || What Blogger Needs,,, But Don't Have.. » || 301 permanent Redirect » || How Google Rank Videos » || Alt Attribute Importance In SEO » || Adsense Secrets - Earn More with Adsense »

How To Prevent Image Hotlinking


One of the most annoying things for webmasters is to find someone else using their template and their images, Especially when they hotlink to these images. Hotlinking is when your images on your server are being displayed on another site. Usually hotlinking is not too much of a problem, But if the image is large, Your own work or using a lot of bandwidth you will want to look into preventing hotlinking.

In this blog entry i will explain how to prevent hotlinking of images with a .htaccess file.
First i will post the code you need to drop into your .htaccess file and then i will explain what each line does and how it prevents hotlinking.

RewriteEngine on
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://(www\.)?domain(/)?.*$ [NC]
RewriteRule .*\.(gif|jpe?g|png|bmp)$ [F,NC]


The first line in this code instructs the server to turn the mod_rewrite engine on.
The second line is checking to see if the referrer string is blank.
The third line instructs the server which domains are allowed to hotlink to your images. If you want to allow more than one domain to use your images simply copy the line and paste it under it and replace the domain with the second domain allowed to hotlink your images, You can do this as many times as you want.
The fourth line tells the server what types of files you want to protect from hotlinking.
This code sample will protect all files with the extention gif, jpeg, jpg, png and bmp.

Another option for preventing hotlinking is to display an image of your choice, no matter what image is linked to.
If you are preventing hotlinking to save bandwidth you wont want to use this option because an image will still be displayed on their site, But it wont be the image they think they are hotlinking to.

Use the following code to prevent hotlinking and display an image of your choice.

RewriteEngine on
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://(www\.)?domain(/)?.*$ [NC]
RewriteRule \.(gif|jpe?g|png|bmp)$ /images/HOTLINKING.gif [L,NC]


This code is almost identical to the previous code, But instead of just preventing hotlinking it will display the image located on your server at /images/HOTLINKING.gif

In the examples you have to replace domain with your own domain name, Don't include your tld (.net .com .org) though, Just the domain.

Labels: ,

| How To Get Backlinks »
| Adsense Banned me -- What should i do? »
| Google Adsense Alternatives »
| Google Adsense - Cost Per Action (CPA) »
| What Blogger Needs,,, But Don't Have.. »
| 301 permanent Redirect »
| How Google Rank Videos »
| Alt Attribute Importance In SEO »
| Adsense Secrets - Earn More with Adsense »

Post a Comment