GetSocial

  • Blogging
  • Freebies
  • Freeware
  • How-To
  • Make Money Online
  • Mobile



  • How to avoid Hotlinking of file and images using .htaccess hack





    Yesterday, i posted a .htaccess hack to Block Visitors from specific IP using .htaccess

    Today, i am here again to share with you one more .htaccess hack.

    What is HotLinking?

    how to avoid hotlinking of file and images using htaccess hack 298x300 How to avoid Hotlinking of file and images using .htaccess hack


    Avoid / Prevent Hotlinking of images or files (Credit http://www.conquerhosting.com)

    Inline linking (also known as hotlinking, leeching, piggy-backing, direct linking, offsite image grabs and bandwidth theft) is the use of a linked object, often an image, from one site into a web page belonging to a second site. The second site is said to have an inline link to the site where the object is located.


    Recently, i noticed one blogger published a post in his blog, instead of uploading the image in his own site, he linked the image of my site. Every time somebody visits his post, the image will be downloaded from my site.

    There are two problems

    - Loss of bandwidth.
    - Image Theft (you might have created the image after a lot of hardwork and wouldn’t like somebody using your image without your permission)

    There is a way in which you can stop this. It can be done by adding few lines of code in .htaccess.

    Prevent Hotlinking of file and images using .htaccess hack


    I am assuming that you know about .htaccess file. It resides in the root directory of your website. The root directory could be /www/, /httpdocs/ or /public_html/ directories. Any of them depends on the hosting service.

    Make sure you backup .htaccess file before you making any changes.

    1. Login to your hosting service site and open code>.htaccess file. Make sure you backup the file before making any changes.
    2. Add the following code in code>.htaccess file and save the file.
      RewriteEngine on
      RewriteCond %{HTTP_REFERER} !^http://niharsworld.com/.*$ [NC]
      RewriteCond %{HTTP_REFERER} !^http://niharsworld.com$ [NC]
      RewriteCond %{HTTP_REFERER} !^http://www.niharsworld.com/.*$ [NC]
      RewriteCond %{HTTP_REFERER} !^http://www.niharsworld.com$ [NC]
      RewriteRule .*.(htm|jpg|jpeg|bmp|png|gif)$ - [F,NC]
    3. From the above line, you can make out that i am blocking hotlinking of htm, jpg, jpeg, bmp, png, gif files.

      You may remove or add any file extension that you want to avoid HotLinked.

    If you know any other way, please share via comments. Hope you learned something from this post!

    Technorati Tags: ,

    IMPORTANT: This blog welcomes Guest Bloggers, Writers to also contribute by writing Guest Posts and also Make Money!. Check out our Revenue Sharing Program

    For Further Reading:

    1. Access Internet Safely and Block illegal websites with Clear Cloud DNS Service for FREE
    2. How to Block Visitors from specific IP using .htaccess hack
    3. Hide Google+ Notification from Google Bar [ How-To ]
    4. Apple’s iCloud: What it is? How it Works?
    5. How to Video / Voice Chat on Nexus S from Google Talk
    6. Two best Programs to speed up your firefox
    7. How to Change User Account Picture Tile in Windows 8 Taskbar
    8. How to Install Windows 8 on USB Drive with Portable Workspace Feature [ FULL GUIDE ]
    Posted under: How-To, TipsNTricks, Webmasters
    2049 readers are already subscribed to this blog! Why don't you be one of them? Subscribe to this blog via your favorite RSS feed reader or by entering your email address on the form below:








    23 Comments

    1. Lyndi says:

      I dislike hot-linkers almost as much as I dislike spammers. This little hack should sort them out. Thanks for this.

      Lyndis last blog post..WordPress Upgrades

      • Nihar says:

        @Lyndi, Me too. There is one problem. If we are using google gears or importing posts along with images to our local wordpress. If this rule is there then we won’t get the images. For that we need to comment out that line temporarily.

    2. Gagan says:

      this one is very useful, cute little trick. will help me a lot.

      Gagans last blog post..TheLast84 : Latest Blogger Template From BeepTheGeek

    3. Atul says:

      very useful post I’ll soon implement it. Never even thought of this Thanks

      Atuls last blog post..Words Women Mostly Use

    4. This is awesome! Thank you for the hack, I’m going to try it right now

    5. Chetan says:

      Playing with .htaccess file is really risky task, but its very powerful file in hosting. Thanks for sharing this trick.and yes backup for that file is also important.

      BTW Nice theme dude. :)

      Chetans last blog post..Google Pagerank 5 for me : Google just updated pagerank

    6. Ruchi says:

      Thanks Nihar, I was looking for it that how to ban the hotlinking, I will give it a try.

    7. Ramakanth says:

      Thanks for sharing this trick,i was facing this problem those leechers are killing my bandwidth,that’s why currently I’m using free photo-sharing sites,anyway thanks for sharing.

      Ramakanths last blog post..First Google chrome extensions are available

    8. Laptops says:

      thanks for sharing this trick, i have an site from which i have noticed alot of hot linking and my bandwidth exceeds earlier because of that,Now this is going to save me,

    9. [...] the past, i have shared a trick – How to avoid hotlinking of images using .htaccess hack. This trick will help you avoid [...]

    10. ravi says:

      Thanks for sharing this trick,i was facing this problem those leechers are killing my bandwidth,that

    11. Brian Smith says:

      Smart little hack, thanks for sharing. It’s really annoying to have images hotlinked all over the place, especially if it’s done systematically by competitors.

    12. linda says:

      Thanks for sharing,very useful tips

    Leave a Reply

    CommentLuv badge

    Notify me of followup comments via e-mail. You can also subscribe without commenting.

    page counter
    NiharsWorld on Twitter NiharsWorld on Facebook NiharsWorld RSS Feed