Home Index

Welcome, Guest
Welcome, Guest. Please login or register.
May 19, 2012, 04:45:48 am
Search:  
Advanced search
WJD Forum Index  |  WestHost Related  |  .htaccess Files  |  Topic: Stopping Hot Linking
Pages: [1] |   Go Down
Print
Author Topic: Stopping Hot Linking  (Read 3911 times)
Shawn Sorrell
Administrator
Jr. Member
*****
Offline

Gender: Male
Posts: 64



WWW
« on: March 14, 2004, 07:44:47 am »

Many folks want to keep others from linking to thier images from other sites.  This can be accomplished by placeing a .htaccess file in the directory where you have your images.  It would look something like this.
Code:
Rewriteengine on
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://domain.com/.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http://www.domain.com/.*$ [NC]
RewriteRule \.(gif|jpg)$ http://domain.com/alternate.gif [R,NC]


The code is five lines only in case it does not display correctly on your computer.  Each line starts with Rewrite.  This well work on WestHost servers but if you are with another hosting company it may not work if they do not allow you to us Rewrite or .htaccess files.

What this well do is instead of showing the image they had wanted to from your server it well display the alternate.gif that you have in your root www directory.  This file must not be in that directory but in one below it where have your images for the rest of your site. You would replace domain with your domain name and the last line is the url path to the image you want to show.

You can allow other domains to use images from your site if would like by simply adding them in using the format of lines 4 and 5.
Logged

Shawn Sorrell
Remember I am not an expert but a jack of all trades.  Information posted here should be used at your own risk. You are responsible for any changes you make to your account/website.
Pages: [1] |   Go Up
Print
WJD Forum Index  |  WestHost Related  |  .htaccess Files  |  Topic: Stopping Hot Linking
Jump to:  

Powered by SMF 1.1.11 | SMF © 2006-2009, Simple Machines LLC