iSnare.com - Free Content Articles Directory
Authors Contents [Advanced Search][Add OpenSearch][Job Search]
Distribute your articles to thousands of article sites for only $2 and below! Read more...

Index  Computers and Technology
 

How To Block Direct Image Linking Using .htaccess

 
[ Contact the Author] [ Send to a Friend] [ Article Publisher] [Make PDF] [ Print] [ Bookmark & Share]
 
Read our Terms of Service before reprinting this article. The submitter specified above has claimed the rights to this article.
Danny Wirken

Most of us have a specified limit to the amount of traffic our web servers will handle for us. That limit seems very generous – until you start looking at image downloads and the bandwidth required. A few dozen users downloading an image – that's one thing. But what if you have an image that dozens of other websites like?

Worst-case scenario: suppose you run a site that gets hold of a picture taken by an Iraqi soldier of an incident that gains a lot of media attention. And suppose you have the exclusive rights to that image. You want to sell it, of course, not give it away, so you don't post it as a freebie. You may have a downloadable version that others can take away to post on their own website, generally with a link to your site. But your original image is reserved for your use only.

Here's the problem. Webmasters, often amateurs not really understanding why what they are doing is harmful, want to deliver the best possible image to their own readers. So instead of downloading your free file or linking to your site, they embed a link in their own page that downloads your picture, and only your picture, as part of their own website. This is easy to do; all you have to do is use the image link straight out to the other website.

With that excellent and lucrative image referenced above, you may have blogs on both sides indexing you; you may even have news sites or image sites indexing you. How much bandwidth can your site take before it exceeds your monthly limit? Chances are, even a medium-case scenario is going to turn your site into a DNS instead, and you will lose viewers and site ranking while you are unavailable. Not worth posting that great picture anymore, is it?

But you do have another option: the .htaccess file. This works primarily in Apache servers; if you're not certain what you've got, call and ask. Because not all systems will allow them, and some can even be damaged by improper .htaccessing, you should contact your server administrator before you upload one, anyway.

What Is .htaccess?

.htaccess is a type of file that has, for years, been used to restrict access to protected web pages or areas, such as error pages and password-protected directories. You create it using a text editor such as NotePad or SimpleText, and then save as plain (ASCII) text. Upon saving it, the file extension needs to be changed from .txt to .htaccess – and the rest of the name needs to be left off. Your file should be named nothing except for .htaccess. Not file.htaccess. Just .htaccess.

If your text program insists on appending the .txt, you can right-click the file anywhere you normally open it and select Rename to remove the .txt. If your computer system does not show file extensions, look up how to make it show them! Alternately, telnet and ftp programs will also allow you to rename files and remove extensions.

Creating .htaccess Files

Your first step in creating this file should be to open your text editor and save an empty page as .htaccess. Turn off your word wrap function..htaccess files are intended to be single-line commands, and a word wrap can throw this completely off and make your file unusable, either by breaking lines in the wrong place or by putting in unwanted characters when it's uploaded.

When you upload an .htaccess file, it should be encoded as ASCII, not binary. CHMOD the file to either 644 or (RW-R—R--) so that the server can use it but a browser cannot; readable .htaccess files can compromise your security by allowing hackers to figure out what you have protected and where the authentication files are. (You can also prevent this problem by putting your authentication files above the root directory so that they cannot be accessed via www.)

An .htaccess file affects the directory it's placed in as well as any subsequent subdirectories; if you have files everywhere you want protected, you can put the .htaccess file in your root directory. If you only want to protect your images, you can put it in your images directory alone. The closest .htaccess file to any given directory, reading up the directory tree, is the one that is applied to that specific directory. Try to use the fewest number of .htaccess files possible; redundancies can cause an infinite loop, which is bad for your site.

Preventing Hot Linking

The most important thing you want to do with an .htaccess file is prevent hot linking of non-HTML objects like images and movies. Hot linking is often referred to as "bandwidth stealing."

Your .htaccess file will disallow hotlinking; instead of the image your thief is trying to use, they'll get something else, like a broken image symbol or content you specify (angry men are popular).

Your .htaccess file content should read as follows:

RewriteEngine on
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://(www\.)?mydomain.com/.*$ [NC]
RewriteRule \.(gifjpg)$ - [F]

The first two lines you don't have to modify in any way. However, the third line's http://mydomain.com needs to be modified to reflect your URL. The fourth line in the example is set up to deny use of GIFs and JPEGs; you can add, using a pipe () separator, any other file type you wish.

If your server is set up to deliver alternate content (call your server administrator and ask), you can add another piece to the fourth line of code in the .htaccess file to do this:

RewriteRule \.(gifjpg)$ http://www.mydomain.com/angryman.gif [R,L]

This delivers an angry-man image you have in your directory; just as above, make certain you change that domain name to the proper one.

Important NoticeDISCLAIMER: All information, content, and data in this article are sole opinions and/or findings of the individual user or organization that registered and submitted this article at Isnare.com without any fee. The article is strictly for educational or entertainment purposes only and should not be used in any way, implemented or applied without consultation from a professional. We at Isnare.com do not, in anyway, contribute or include our own findings, facts and opinions in any articles presented in this site. Publishing this article does not constitute Isnare.com's support or sponsorship for this article. Isnare.com is an article publishing service. Please read our Terms of Service for more information.

Article Tags: file [See Dictionary], htaccess [See Dictionary], image [See Dictionary]
Got a question about this article? Ask the community!
Article published on July 26, 2006 at Isnare.com
 
Rate this article:

Microsoft To Conquer Localized Media Delivery Problems
Submitted by: Danny Wirken

From the time that commercial paid advertisements and other media content came into being, it inadvertently led to an increase in the demand for more highly targeted and effective marketing campaigns on the Internet...

Microsoft To Integrate Rss Support In Windows Operating System
Submitted by: Danny Wirken

Last year Microsoft Corporation shocked the world when they revealed their intention to build RSS (Really Simple Syndication) support in the latest version of the Microsoft Windows operating system, which is under the code-name “Longhorn...

The Latest Patent Applications: Kernel Of Technological Advancement
Submitted by: Danny Wirken

The value of freedom in a country is priceless If one country has freedom of speech and thought then they are sure to have a bright future ahead of them...

Understanding Support Vector Machines (SVMs) Classifiers
Submitted by: Danny Wirken

The past couple of years witnessed the increased applications of statistical methods in different fields and for different purposes...

Why Wireless DA Is A Multi-Billion Dollar Industry
Submitted by: Danny Wirken

Wireless Directory Assistance (DA) is a virtual directory that offers a fast way to get directory-dependent applications online...

Wordpress Version 2.0.3 Review
Submitted by: Danny Wirken

WordPress, the premier free open-source blogging utility, has gone through several upgrades in its life...

Improving Customer Service Through Help Desk Software
Submitted by: Danny Wirken

Help desk have now become a core part of good business service and operation The term itself is generally associated with the end user support center...

Apple Tiger vs Windows Vista
Submitted by: Danny Wirken

Microsoft’s next-generation operating system is coming in early 2007, offering improvements that are both impressive and unprecedented in the Windows world...

Accessory Computer
Submitted by: Danny Wirken

A home away from home is a great thing, so why not have an office away from the office tooThe spare room or a quiet corner can be a perfect place for productivity...

Plantronics DSP 400 Headset
Submitted by: Danny Wirken

The Plantronics DSP 400 headset produces high quality sound whether you use it with a laptop or a desktop computer...

Diner Dash
Submitted by: Danny Wirken

Diner Dash is all about a young burnt out corporate employee named Flo She gets tired of running the rat race and so opens up her own restaurant...

Avast Antivirus Home Edition
Submitted by: Danny Wirken

Prior to trying the Avast 46 Home Edition, I was very much a Norton user...

Bookworm
Submitted by: Danny Wirken

Bookworm is a very good alternative to some of the violent action games popular today The goal is simple: spell words by linking letters found on the board...

Apple iPod Special U2 Edition
Submitted by: Danny Wirken

New iPod models have sprung up as quickly as mushrooms after the rain and each time they just seem to get better and better...

Zuma Deluxe
Submitted by: Danny Wirken

Zuma is one of those arcade games that starts off really easy and becomes more difficult with each level...

How to Install Aftermarket Stereo in Vauxhall Agila
Submitted by: Jack Wylde

DESCRIPTION: The radio installation in VAUXHALL AGILA Some Cars have steering controls from new and when you replace your radio...

Don't Ruin Your Laminator - 4 Reasons to Always Use a Carrier With Your Pouch Laminating Machine
Submitted by: Jeff McRitchie

One of the most important supplies you'll need when getting ready to use a pouch laminator is a carrier...

5 Reasons to Consider the Destroyit 4107 Cross Cut Shredder
Submitted by: Jeff McRitchie

There is shredding, and then there is "Shredding" The Destroyit 4107 is a heavy duty shredder that can handle just about anything any sized office can throw at it...

Reviewing the Akiles CombMac 24E Electric Plastic Comb Binding Machine
Submitted by: Jeff McRitchie

Because it is a rare electric comb binding systems on the market that works with legal size sheets, the Akiles CombMac 24E already has somewhat of a competitive advantage...

Reviewing the Akiles DuoMac 321 Combination 3:1 and 2:1 Pitch Wire Binding Machine
Submitted by: Jeff McRitchie

Offering some nice flexibility in binding styles, the Akiles DuoMac 321 is positioned as a binding solution for businesses and organizations that want the ability to bind documents in as many as five binding styles...

Reviewing the Akiles DuoMac 421 Combination 4:1 Pitch Coil and 2:1 Pitch Wire Binding Machine
Submitted by: Jeff McRitchie

The Akiles DuoMac 421 is a combination binding system that offers medium volume users with three different binding styles...

PC Virus Removal Can Help Businesses Save Millions of Dollars
Submitted by: Adrianna Noton

The business world is now, for the most part, driven by technology The internet is of fundamental importance to the success of a business...

GBC ShredMaster CC195 Cross-Cut Shredder Review
Submitted by: Jeff McRitchie

If you've visited an office supply store recently or checked out paper shredders on the Internet, it probably seems like paper shredders are all alike, especially in the looks department...

Frequently Asked Questions About Spiral Coil Binding
Submitted by: Jeff McRitchie

Coil binding - also known as spiral binding - is a very popular method of binding, but it can be difficult to understand how it's done...

An Overview of the GBC C-75 Comb Binding Machine
Submitted by: Jeff McRitchie

If you are looking for an inexpensive comb binding machine for your office or home office you might be considering the GBC C75...

5 Great Features of the Rhin-O-Tuff HD6500
Submitted by: Jeff McRitchie

Designed for the heaviest duty users such as print and copy shops, binderies and large organizations, the Rhino Tuff HD6500 is a machine that offers top of the line flexibility and capacity...

Sony Ericsson W595 Mobile Phone Review - The Latest and Best Walkman Phone?
Submitted by: Carlson Osbourne

The one thing that most Sony Ericsson phones have in abundance is good looks No matter what lies beneath the surface, they all tend to have unique and beautiful appearances that can enhance the style factor of everyone using them...

Comparing the Swingline SmartCut EasyBlade and EasyBlade Plus Rotary Trimmers
Submitted by: Jeff McRitchie

At first glance, Swingline's SmartCut EasyBlade and EasyBlade Plus may look very similar, except for the price...

Five Reasons to Consider the Rhino-Tuff OD4000 Modular Binding Punch
Submitted by: Jeff McRitchie

Though it may be the smallest of Rhino's electric interchangeable punches, the OD4000 offers you about as much as a binding punch can offer...

Sony Ericsson W705 Mobile Phone Review - Tune Into the Beat With the Ultimate Walkman Phone
Submitted by: Carlson Osbourne

Sony Ericsson is known the world over for their amazingly functional and stylish mobile phones It is easy to see why when you take a look at some of the handsets that they have produced over the years and one of their latest additions to the Walkman range can be added to that illustrious list...

Isnare.com Footer Divider

© 2004-2009. Isnare Free Articles - An Isnare Online Technologies Free Articles Project. All Rights Reserved.   Privacy Policy