PHP Magic Book – Free PHP Scripts, Tutorials and Downloads, PHP AtoZ Reloaded, free php tutorials, free php downloads, php scripts, PHP tips

Protect Hotlink the Right Way Using htaccess

Protect hotlinking the right way. There are content stealers out there who will copy your links and images and display them at their websites in result of which you pay more for bandwidth. If you do not do it the right way, you can block google and feedburner also. Here is a code to do it the right way. Any incoming direct request for your image file, zip file or rar will will display your specified image instead of that.

Add this code into your .htaccess file and make sure you change ‘yoursitename’ there.

Options +FollowSymlinks
# Protect Hotlinking
RewriteEngine On
RewriteCond %{HTTP_REFERER} !^http://(.+.)?yoursitename.com/ [NC]
RewriteCond %{HTTP_REFERER} !^http://(www.)?google.com/.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http://(www.)?feedburner.com/.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http://(www.)?feeds2.feedburner.com/.*$ [NC]
RewriteCond %{HTTP_REFERER} !^$
RewriteRule .*.(jpe?g|gif|bmp|png|zip|rar)$ http://yoursitename.com/someimage.jpg [L]
  • Share/Bookmark
Tags: , ,
Posted in: htaccess
Post's RSS » RSS 2.0
Post's Comments RSS » RSS 2.0

Related Posts




4 Responses to “Protect Hotlink the Right Way Using htaccess”

  1. Jan 3, 2010
    iphone konig Says:

    thanks for this – happy holidays :D

  2. Jan 4, 2010
    iphonekönig Says:

    happy new year – love your blog

  3. Jan 4, 2010
    Nick Matyas Says:

    this is an outstanding blog
    the way u write is fabolous.
    Thanks a lot

  1. 1 Trackback(s)

  2. Dec 31, 2009: Protect Hotlink the Right Way Using htaccess - htaccess - PHP … Scripts Rss

Post a Comment

  Subscribe Via RSS
  Subscribe Via Email