Lunarpages Web Hosting Forum

Author Topic: How To: Correct the issue with hotlink protection  (Read 15318 times)

Offline Hush

  • Über Jedi
  • *****
  • Posts: 2830
How To: Correct the issue with hotlink protection
« on: November 22, 2003, 08:47:15 PM »
The Issue

Hotlink protection is undeniably a good thing.  However, when using the tool in CPanel, it will not support browsing to the domain without the trailing / mark.  That means that

Quote from: Supported Addresses

http://www.yourdomain.com/
and
http://www.yourdomain.com/index.htm


Will show your images as expected, however,

Quote from: Un-supported Addresses

http://www.yourdomain.com


will not.  At this point, I should point out that CPanel is not a Lunar Pages product, so whilst we make recommendations for updates, we are not directly able to control these updates.

To make the hotlink protection work correctly, you will need to do a small amount of editing to your .htaccess file.  No this How To: is concentrating on protecting your whole site, I will deal with protecting parts of your site in another How To: and so you will be using the .htaccess found directly inside your public_html folder today.

To make this tutorial as easy as possible we will be using the Hotlink Protection tool inside CPanel.  So start by logining into your account, and clicking on the Hotlink protection icon.  The first thing you should notice is the very large white box on the screen.  This is where you type in the URLs that you want to allow to 'Hotlink' to your site.

Simply type in the urls that you want to allow to hotlink as you would type them into a browser, for example our URLs would be typed:

Quote from: Lunar Forums Example URL

http://www.lunarforums.com


Be sure only to type in the format above, do not worry about typing addresses with and without the www. prefix, or with a page afterwards, such as index.htm, as we will take care of this soon.

Click on the 'Activate' button.  This will automatically generate the basic hotlink protection scripting for your .htaccess file, and of course put it in place.

Next step, is to go back to the CPanel (click the 'home' icon on the CPanel banner). Click on File Manager, then click on the folder icon next to public_html to enter the folder, followed by clicking on the word .htaccess.  On the right hand side of the screen, a menu will appear, click on 'edit file'.

What you should see is a screen with some lines of code as follows (I have used the lunarpages and lunarforums from above, your code will have your domain in it)

Quote from: Code Entered Into .htaccess By Hotlink Protection

RewriteEngine on
RewriteCond %{HTTP_REFERER} !^http://www.luarforums.com/.*$      [NC]
RewriteRule .*\.(jpg|jpeg|gif|png|bmp)$ - [F,NC]


Now, here's the good bit.  I want you to change the text to include the parts below in red, so it looks like this example.

Quote from: Changes To .htaccess Codes

RewriteEngine on
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://(www\.)?lunarforum.com(/)?.*$     [NC]
RewriteRule .*\.(gif|jpg|jpeg|bmp)$ - [F,NC]


Click on the save button at the bottom of this page.  That's it, your site is now hotlink protected, and people will be able to view the site from just typing in your domain name, even without the trailing / mark.
<- From the ashes will rise a phoenix ->

Lunarpages Web Hosting || Lunarpages Forums || Lunarpages Affiliate Program

leighsww

  • Guest
How To: Correct the issue with hotlink protection
« Reply #1 on: November 23, 2003, 03:46:03 PM »
Excellent, Hush!  Thanks!

This REALLY was a useful tip!  I had already read another thread that you shared this info, so I had done it a few days ago, but just wanted to let you know how GREAT this tip was!

Offline Hush

  • Über Jedi
  • *****
  • Posts: 2830
How To: Correct the issue with hotlink protection
« Reply #2 on: November 24, 2003, 06:33:47 AM »
Oh gosche...  :oops:  Thanks.
<- From the ashes will rise a phoenix ->

Lunarpages Web Hosting || Lunarpages Forums || Lunarpages Affiliate Program

Offline jsinger

  • Spaceship Captain
  • *****
  • Posts: 114
How To: Correct the issue with hotlink protection
« Reply #3 on: December 09, 2003, 01:43:07 PM »
I tried the hotlink protection in my .htaccess file but it doesn't seem to be working.

I have this in my .htaccess file (located in my public_html directory):
RewriteEngine on
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://(www\.)?jeffsingerphotography.com(/)?.*$     [NC]
RewriteRule .*\.(gif|jpg|jpeg|bmp)$ - [F,NC]

I then created the following page to test it:
http://homepage.mac.com/jhsinger/testhotlink.html

I'm still seeing the image being linked.

Jeff

Offline Hush

  • Über Jedi
  • *****
  • Posts: 2830
How To: Correct the issue with hotlink protection
« Reply #4 on: December 09, 2003, 01:47:34 PM »
I have just visited the site you have given in your message, and the image is not showing.

I would say that this is probably cached.  Try emptying your temporary internet files/cache and reloading the page.
<- From the ashes will rise a phoenix ->

Lunarpages Web Hosting || Lunarpages Forums || Lunarpages Affiliate Program

Offline jsinger

  • Spaceship Captain
  • *****
  • Posts: 114
How To: Correct the issue with hotlink protection
« Reply #5 on: December 09, 2003, 01:50:29 PM »
Hmmm, I cleard my cache and it was still showing up... but I did it again after a reboot now its not showing up... DOH!

Jeff

Offline Hush

  • Über Jedi
  • *****
  • Posts: 2830
How To: Correct the issue with hotlink protection
« Reply #6 on: December 09, 2003, 01:54:21 PM »
The power of the Internet, and ghosting files  :?

Glad it's working for you though...  Hotlink protection can be a major factor in reducing a web site's bandwidth use.
<- From the ashes will rise a phoenix ->

Lunarpages Web Hosting || Lunarpages Forums || Lunarpages Affiliate Program

Offline jsinger

  • Spaceship Captain
  • *****
  • Posts: 114
How To: Correct the issue with hotlink protection
« Reply #7 on: December 09, 2003, 02:07:34 PM »
Yes, its of particular interest to me as a photographer.

On a related note, how does this (if at all) effect search engine spiders and how they crawl my site?

Offline Stephanie®

  • Master Jedi
  • *****
  • Posts: 1090
How To: Correct the issue with hotlink protection
« Reply #8 on: December 09, 2003, 02:31:00 PM »
It won't affect your search engine ratings.

Most bots look for Meta tags/descriptions/keywords and links, images are not an issue.

Offline mscnts

  • Spacescooter Operator
  • *****
  • Posts: 42
How To: Correct the issue with hotlink protection
« Reply #9 on: December 28, 2003, 05:00:10 PM »
Hello.. would you be so kind to explain exactly what 'hotlink protection' is all about?
These 'how to:' posts are great and detailed, but unless you know what you want to do and why, they don't help us green beginners... lol   It would be perfect if you could start a 'how to' with a 'what this is/does/creates' paragraph.  Much appreciated!

Offline Hush

  • Über Jedi
  • *****
  • Posts: 2830
How To: Correct the issue with hotlink protection
« Reply #10 on: December 28, 2003, 05:30:48 PM »
Sorry,  that is an absolutely excellent point.

Hotlink Protection 101:

When you place files on your server (for instance images and video files), they can be viewed by anyone who visits your web site.  This takes up an amount of bandwidth (the size of the file).  However it is possible to link from one site to another and display files.

For instance, if you look through the graphics forum here at Lunar Forums you will see many images on display.  These images are hosted at the web site of the person who posted them.  A link to the image is added to the post in a similar way as if this forum were the person's own site.  This then takes the image from the user's site to display here.  This means that the user will have their bandwidth used for displaying the image.

This is known as hotlinking.  It can be put to great use.  However it can also be abused.  Imaging if you have a video file that is 20 MB in size, and your site gets a hundred people a day view it.  No real problem, your monthly bandwidth usage for this file will be approximately 60 GB (roughly calculated for simplicity).  However, someone sees this video and want's it on their site.  If they downloaded it, and then uploaded directly to their server to link to, it wouldn't impact your bandwidth.  However, say they are expecting 500 people to view it every day.  They may just link to the file on your server, so as not to use up their bandwidth.  Now your monthly bandwidth for this file may go up to 360 GB!

Hotlink protection stops files from being linked to, or viewed directly.  However, you are able to specify which domains are able to hotlink to your media in order that you can, for example, post images on forums.

Thanks for asking, it is all too easy to write the answer, when many people who view it will not be aware of the question.  :thumb:
<- From the ashes will rise a phoenix ->

Lunarpages Web Hosting || Lunarpages Forums || Lunarpages Affiliate Program

Offline mscnts

  • Spacescooter Operator
  • *****
  • Posts: 42
How To: Correct the issue with hotlink protection
« Reply #11 on: December 28, 2003, 05:48:33 PM »
Aaaahhhhh.... *she says, nodding in complete understanding of the explanation.*   That makes perfect sense to me now!

Thanks for the quick reply!

Offline Hush

  • Über Jedi
  • *****
  • Posts: 2830
How To: Correct the issue with hotlink protection
« Reply #12 on: December 28, 2003, 08:12:23 PM »
:D  All part of the service  :thumb:
<- From the ashes will rise a phoenix ->

Lunarpages Web Hosting || Lunarpages Forums || Lunarpages Affiliate Program

Offline EJ

  • Galactic Royalty
  • *****
  • Posts: 247
How To: Correct the issue with hotlink protection
« Reply #13 on: January 13, 2004, 09:42:10 AM »
Hey Hush???

heres what my says/looks like

RewriteEngine on
RewriteCond %{HTTP_REFERER} !^http://www.graphics.steelsheen.com/.*$      [NC]
RewriteCond %{HTTP_REFERER} !^http://www.graphics.steelsheen.com$      [NC]
RewriteCond %{HTTP_REFERER} !^http://www.steelsheen.com/.*$      [NC]
RewriteCond %{HTTP_REFERER} !^http://www.steelsheen.com$      [NC]



Why are there "clones"? can I delete those? and which ones exactly would I delete?

edit: OK here's what it looks like now, I havent deleted those clones, Don't know if I should

RewriteEngine on
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://(www\.)?graphics.steelsheen.com(/)?.*$      [NC]
RewriteCond %{HTTP_REFERER} !^http://www.graphics.steelsheen.com$      [NC]
RewriteCond %{HTTP_REFERER} !^http://(www\.)?steelsheen.com(/)?.*$      [NC]
RewriteCond %{HTTP_REFERER} !^http://www.steelsheen.com$      [NC]

Is this correct?
I love the new LPF theme

Offline EJ

  • Galactic Royalty
  • *****
  • Posts: 247
How To: Correct the issue with hotlink protection
« Reply #14 on: January 22, 2004, 05:48:51 PM »
OK cpanel hot link sucks, sometimes it works sometimes it doesnt, my avatar was working now its not, yet oddly my pictures are still showing on other websites. I did everythng above. Everytime I update it (like adding a redirect url which doesnt work anyway!) I get 50 million clones...I give up :(
I love the new LPF theme