Prevent hotlinking of images!

by elsoar
9 replies
  • WEB DESIGN
  • |
I have a site and blog, the pictures are stolen from them, I want a simple code to disallow of my files to view on other sites.
#hotlinking #images #prevent
  • Profile picture of the author DanielBlue
    If I remember right there is a easy way to do so in cpanel but is has some disadvantages when it comes to SEO.
    {{ DiscussionBoard.errors[9786975].message }}
  • Profile picture of the author elsoar
    is there an easy way in .htaccess?
    {{ DiscussionBoard.errors[9790416].message }}
    • Profile picture of the author kumarraj
      Originally Posted by elsoar View Post

      is there an easy way in .htaccess?
      I guess you can try this in your htaccess file, do replace yourdomain with your actual domain and extension.
      Code:
      RewriteEngine on
      RewriteCond %{HTTP_REFERER} !^$
      RewriteCond %{HTTP_REFERER} !^http(s)?://(www.)?yourdomain.com [NC]
      RewriteRule .(jpg|jpeg|png|gif)$ - [NC,F,L]
      Let me know if you require any other help.
      Regards,
      Raj
      {{ DiscussionBoard.errors[9791632].message }}
  • Profile picture of the author elsoar
    @kumarraj
    Not Work!
    {{ DiscussionBoard.errors[9791680].message }}
    • Profile picture of the author Rembo
      Originally Posted by elsoar View Post

      @kumarraj
      Not Work!
      Are you using Apache?
      Then the above script should work. If not, try placing this particular .htaccess file in the directory where your images are stored. Does it work then?

      If you're not using Apache you will need to solve this differently.

      Also make sure that if you use any caching on your website make sure you flush it.

      If you use a CDN follow directions from them.

      For most CMS's there are also hotlink protection plugins. If you are using a CMS you could give those a go as well although most of them will probably also alter the .htaccess in the root.
      Signature
      Smarter Affiliate Money. Work Smarter, Earn More.
      {{ DiscussionBoard.errors[9791743].message }}
    • Profile picture of the author kumarraj
      Originally Posted by elsoar View Post

      @kumarraj
      Not Work!
      I am sure that code within htaccess will help you prevent hot linking from your site. But there are some requirements like Rembo said, it needs to be a server that understands htaccess.

      Can you post the htaccess code you used for your site, there can be some issues in that too.

      Link that sunoy14 has posted is good too.
      {{ DiscussionBoard.errors[9794051].message }}
  • Profile picture of the author KirkMcD
    You said they stole the images. Hot linking isn't stealing.
    If they are not hot linking the images and just copied them to the other site, the rewrite won't do anything.
    {{ DiscussionBoard.errors[9792672].message }}
    • Profile picture of the author elsoar
      Originally Posted by KirkMcD View Post

      You said they stole the images. Hot linking isn't stealing.
      If they are not hot linking the images and just copied them to the other site, the rewrite won't do anything.
      I know this, but I do not want to lose my RAM, or bandwidth..
      {{ DiscussionBoard.errors[9793109].message }}
  • Profile picture of the author sunoy14
    You might want to check out this tutorial at hongkiat. The person does it through .htaccess
    Smarter Way To Prevent Image Hotlinking with .htaccess
    Signature

    "wordpress plugins" & "blogging tutorials" www.rom-link.com
    Free guitar lessons www.mamamusicians.com

    {{ DiscussionBoard.errors[9793283].message }}

Trending Topics