June 20

0 comments

How to prevent hotlinking with Frontpage published sites.

By Christopher Mendla

June 20, 2007

Cpanel

Last Updated on December 4, 2019 by Christopher G Mendla

I just got a notice that one of my sites was at 80% bandwidth. There was still over a week left in the month. When I checked the logs, there were a couple of forums hotlinking to my images. Hotlinking is where someone uses a link to one of your images on their site, a forum or a blog. The problem is that if it is a high traffic site, the traffic can kill your bandwith allowance.

I’m using frontpage and FP is a pain about messing with the htaccess file at the root. If I tried to enable hotlink protection via cpanel, it broke the fp extensions (yeah, I know, move off FP)…

WARNING- Be careful with the following. It did not break my site, but it could break other FP sites. Backup first and use at your own risk.

You can read up on the .htaccess file commands a simple htaccess file that will block hotlinking would be

RewriteEngine on
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://mysite.com/.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http://mysite.com$ [NC]
RewriteCond %{HTTP_REFERER} !^http://www.mysite.com/.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http://www.mysite.com$ [NC]
RewriteRule .*.(jpgjpeggifpngbmp)$ – [F,NC]

If you put this .htaccess file at the root, you will mess up FrontPage. The trick is to put all of your images into the images folder or it’s subfolders. By nature, subfolders inherit the htaccess of their parents. The htaccess file you create will go into the images folder of your site.

You should customize the file to meet your needs.

  1. Go to the file manager in cpanel and find your images folder.
  2. Create a file called .htaccess (the period at the beginning is critical)
  3. Put in your code similar to above (with your site name and not mysite)
  4. Test to see if hotlinking will work on your images (a) Go to one of your pages (2) right click on an image and look at the properties (3) copy the image location (4) test it in a hotlink checker such as http://altlab.com/hotlinkchecker.php
  5. Test to make sure that you can publish with frontpage and that your site is working, especially FrontPage specific items such as forms.

Keep in mind that if you reinstall the Frontpage Extensions, your .htaccess file in the images folder will probabloy be renamed (or deleted). If it was renamed, you can simply go into cpanel’s file manager and name it back to .htaccess. If it was deleted, hopefully, you saved it locally and can either created it in cpanel’s file manager or upload it via ftp. REMEMBER to create it in the images folder, NOT the public_html root folder.

Again, there is some risk to this but it is becoming necessary due to rude behaviour. (Hotlinking)

Christopher Mendla

About the author

Leave a Reply

Your email address will not be published. Required fields are marked

{"email":"Email address invalid","url":"Website address invalid","required":"Required field missing"}