Lens Diaries Go Now
Glamour, Beauty, Nude, Models, Photographers

*    |  Register  


 
Go Back   Garage Glamour™ > Garage Glamour™ Main Forums > Tech Talk Forum
 

Tech Talk Forum Photography & Technical Related Only!

Reply
 
LinkBack Thread Tools Display Modes
Prevent hotlinking
Old 11-27-2006, 11:11 AM   #1 (permalink)
Biker by the Grace of God

 
dynamike's Avatar
 
Join Date: Nov 2002
Member GG#: 35237
Location: St Marys
Posts: 1,552
Comments: 0

dynamike is offline IP: 69.21.92.10
 
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

I run a pretty popular biker e-zine (three month Alexa rank ~70k). A large part of what I do is feature pretty ladies and hot bikes -> http://www.brainbucketmagazine.com/c...ine/cat=2.html. Image theft is a concern for me, but more importantly, bandwidth theft is a bigger one, since I can easily lose loads of money with no ad revenue. Bandwidth theft occurs when someone serves an image from my site by calling it directly from my server. The biggest offenders for me are the yoyo's that post pictures from my site in forums and fusker.com.

I could easily track down each of these offenders and let my lawyer get rich off me while winning nothing more than having the image(s) removed. I like my money and while I like my lawyer, I don't like her as much as my money. I use a much cheaper and more effective means of preventing image hotlinking. I use my .htaccess file!

Here's a little background if you need it. If not skip to the next paragraph. My site runs on an Linux server running Apache. I'm sure you can control things from the root in the same way on a Windows machine, but I don't know how to do it. An .htaccess file can do loads of stuff and it's a pretty powerful little tool. I can password protect directories, prevent viewing of the file structure from a web browser, and even rename files dynamically. Oh yeah, and I can also prevent hotlinking, which is what this is all about. You don't need any special programming skills, or any special software. All you need is a text editor and FTP access to your site. Here's how you do it.

Open your favorite text editor. Save the file in the directory you want to prevent hotlinking from as '.htaccess'. For me, that's my /pics/ folder. Once you upload the file, you'll be able to see it on your machine, but you might not be able to see it on your site's server using an FTP program. Keep the file open.

Add this little bit of code:

RewriteEngine on
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://(www\.)?yourdomain.com(/)?.*$ [NC]
RewriteRule .*\.(gif|jpg|jpeg|bmp)$ [R,NC]
That's it! It's that simple.

Now, what if you want to allow certain sites to serve up images from yours? Easy. All it requires is a little more code. Insert the following line of code for each site you want to allow below the third line from above:
RewriteCond %{HTTP_REFERER} !^http://(www\.)?alloweddomain.com(/)?.*$ [NC]
Here's another little feature I like. It serves up an image instead of the one that's being hotlinked letting the viewers know that they can see the image on my site. Here's the code you should replace the last line with in the first example:

RewriteRule .*\.(gif|jpg|jpeg|bmp)$ http://www.image url to show when someone is hotlinking[R,NC]
For my site, here's what shows


Here's my .htaccess file that protects my image directory:

RewriteEngine on
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://(www\.)?brainbucketmagazine.com(/)?.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http://(www\.)?brainbucketmag.com(/)?.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http://(www\.)?myspace.com(/)?.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http://(www\.)?buletin.myspace.com(/)?.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http://(www\.)?americanmotorcycleclub.com(/)?.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http://(www\.)?member.*************.com(/)?.*$ [NC]
ReWriteCond %{HTTP_REFERER} !^http://(www\.)?glamour1.com(/)?.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http://(www\.)?lexandterryforum.com(/)?.*$ [NC]
RewriteRule .*\.(gif|jpg|jpeg|bmp)$ http://www.brainbucketmagazine.com/hotlink.gif [R,NC]
You can modify it to fit your needs. Once you're done, save the file and upload it to the approproate directory on your server.

Hope this little tip serves you well and saves you some money in bandwidth!

Mike
__________________
  View Public Profile Send a private message to dynamike Visit dynamike's homepage! Find More Posts by dynamike
 
Re: Prevent hotlinking
Old 11-27-2006, 02:54 PM   #2 (permalink)
Free Member

 
R_Fredrick_Smith's Avatar
 
Join Date: Jun 2003
Member GG#: 35872
Location: Dallas/Fort Worth Area
Posts: 3,691
Comments: 41

R_Fredrick_Smith is offline IP: 76.186.138.200
 
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

Yes, I've used one or more of these techniques for many years. I'm sure you already know that the last line you use costs you 7k of bandwidth each time an attempt is made to display one of the hotlinked images.

But for others, if you do have a substitute image, the bandwidth to display it comes from your bandwidth. So keep the graphic as small as possible in file size.

If using a Gif as in this example, then reduce the colors. For example the brain bucket graphic can be reduced by 3K just by changing the Gif setting to 4 colors.

Cheers,
rfs
__________________

"The map is not the Territory"
  View Public Profile Send a private message to R_Fredrick_Smith Visit R_Fredrick_Smith's homepage! Find More Posts by R_Fredrick_Smith
 
Re: Prevent hotlinking
Old 11-27-2006, 04:20 PM   #3 (permalink)
Biker by the Grace of God

 
dynamike's Avatar
 
Join Date: Nov 2002
Member GG#: 35237
Location: St Marys
Posts: 1,552
Comments: 0

dynamike is offline IP: 69.21.92.10
 
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

Quote:
Originally Posted by R_Fredrick_Smith View Post
Yes, I've used one or more of these techniques for many years. I'm sure you already know that the last line you use costs you 7k of bandwidth each time an attempt is made to display one of the hotlinked images.

But for others, if you do have a substitute image, the bandwidth to display it comes from your bandwidth. So keep the graphic as small as possible in file size.

If using a Gif as in this example, then reduce the colors. For example the brain bucket graphic can be reduced by 3K just by changing the Gif setting to 4 colors.

Cheers,
rfs
Thanks for the heads up. However, anything less than the size I have it right now gives me undesirable results.

Just so everyone else knows, you can make your .htaccess file prevent certain sites from hotlinking your images, however, I prefer to allow certain sites instead. The example I have works wonders for me. It prevents lots of bandwidth theft and what bandwidth I do use in the replacement image is worth it when someone types in my URL into their browser.

Mike
__________________
  View Public Profile Send a private message to dynamike Visit dynamike's homepage! Find More Posts by dynamike
 
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On
Trackbacks are Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
hotlinking bchan3rdi Tech Talk Forum 9 02-02-2005 02:28 PM

Sponsors


New To Site? Need Help? Photographer & Model Links
All times are GMT -5. The time now is 12:36 PM.

© 1999-2017 Garage Glamour™




Search Engine Friendly URLs by vBSEO 3.2.0

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94