Prevent Others From Hotlinking

September 15th, 2009
Tags: , , ,
Categories: General, Internet, Linux

You can stop others from hotlinking on your site with the use of the .htaccess file in Apache. Hotlinking is when others are directly linking to an image or a file on your server. It’s bad because, they are using your server’s resources and bandwidth for free. You can edit your .htaccess file usually located in your root directory. If you don’t have one, just create one. It must start with a period, .htaccess. Enter this code:

RewriteEngine On
RewriteCond %{HTTP_REFERER} !^http://(.+\.)?mysite\.com/ [NC]
RewriteCond %{HTTP_REFERER} !^$
RewriteRule .*\.(jpe?g|gif|bmp|png)$ /images/nohotlink.jpe [L]

Read more.

  • Twitter
  • Facebook
  • Digg
  • del.icio.us
  • Google Bookmarks
  • StumbleUpon
  • LinkedIn
  • Technorati
  • FriendFeed
  • Live
  • MySpace
  • Ping.fm
  • Posterous
  • Reddit
  • Slashdot
  • Suggest to Techmeme via Twitter
  • Yahoo! Bookmarks
  • Yahoo! Buzz
  • Print
  • email
  • PDF
  • RSS

Leave a Reply