Main Menu
Articles Home
Most Popular Articles
Top Authors
Submit Articles
Submission Guidelines
Link to Us
Bookmark
Contact Us



Partners
 
Home / Computers

How To Block Direct Image Linking Using .htaccess

By: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 .(gif|jpg)$ - [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 .(gif|jpg)$ 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.



Digg del.icio.us Blink Stumble Spurl Reddit Netscape Furl

Article keywords: internet, SEO, Software development, webmaster

Article Source: http://www.articles2k.com

www.theinternetone.net







Top Computers Articles
  • 1). The danger behind peer-to-peer file sharing  By : Migz Mon
    File sharing is very common nowadays. You can get a P2P (peer-to-peer) program for free, and soon start sharing stuff like music, videos and programs. We use these applications freely and most of us don’t know the risks involved when using them. Questionable reliability of files – Once we get our hands on a P2P program, we download everything we want like crazy.

  • 4). Is The Internet Censored?  By : J Schipper
    When most people think about Internet censorship, the usual suspects immediately come to mind : Communist China and repressive Islamic countries. Unfortunately, Westerners have an embarrassment all their own : Australia's net censorship law, established in 2000. Freedom House, a non-profit U.S. organization dedicated to spreading human rights and freedom, undertakes regular surveys on press freedom and censorship.

  • 5). Toshiba Libertto U100, smaller yet better than you might imagine!  By : john
    Have you ever wondered how small a laptop can be? Well, utilizing today’s technology Toshiba does a perfect job at demonstrating it; the Libertto U100 is one of the very few laptops that have such a rich feature set fitted altogether within such a small space. Of course, if you believe that a fingerprint authentication system is too much for such a.

  • 6). Does CCTV Really Reduce Crime?  By : Robert Michael
    In the UK, home of twenty percent of the world's CCTV cameras, there is mounting concern about its invasion and lack of regulation. "UK Public CCTV Surveillance Regulation Campaign." The thought-provoking questions they ask are good ones. They want to know, for instance, why, if television programming and licensing is so heavily regulated in the UK.

  • 8). Preparation Tips For Comptia A+ Certification  By :
    The Industry Standard CompTIA A Plus Certification exam has two parts; approximately 80 questions for each part. * Core Hardware: $153 - min. passing score 515 * Operating Systems Technology: $153 - min. passing score 505 (CompTIA corporate members can take the exams for $98, employers that require this test are usually corporate members and will inform you of this.

  • 9). Can Cell Phones Harm Your Health?  By : D Ruplinger
    It seems like everywhere a person goes there is at least one person in view with a cell phone to their ear whether it is on the road, in a store, in a parking lot, walking down the street, etc. Even in places where cell phone usage is banned such as concert halls or movie theaters there is the occasional offender, or more likely, at least a few people using the text messaging feature on their phone.


New Computers Articles
  • 5). If You Want Flexibility And Portability Consider A Laptop  By : Gregg Hall
    If you are one of those who works with a computer on a daily basis like me you should consider a laptop. I have actually owned three now and I think I would be lost without mine. I still use my desktop PC quite a bit at home but the laptop comes in extremely handy when I am away.

  • 7). Becoming A DVD Repair Expert Online  By : Maxine Schel
    Many conventional colleges and universities are now offering online DVD repair courses, which are the exact same as those taught on a traditional college campus, to distance learners. Online education is generally taught through the use of several different methods, including online satellite feeds, correspondence or online lessons. This technique permits the student to obtain a DVD repair degree without ever having to step inside of a classroom.

  • 8). Compatible Inkjet Cartridge  By : Isabel Rodrigues
    Once the printer ink runs dry it has to be replaced with another inkjet cartridge. There are many reputed companies like Canon, Epson, Dell, and Lexmark that provide the necessary cartridges to replace the empty cartridges. Replacing inkjet cartridge can add to a very big cost. It could be worse if you have to replace the empty cartridges frequently every month.

  • 9). Best Passwords  By : Richard Romando
    No sane person would ever like someone else reading her email. Or for that matter some other person using her password and breaking into a financial institution. You should, therefore, choose a strong, secure password in such a manner that would be a hard nut to crack for others and easy for you to remember. The more random and mixed-up you make it, the harder it is for others to crack.

  • 10). Home Printing Machines  By : Peter Vermeeren
    Home printing machines are available on the market today in many sizes, prices and capabilities. Many different forms of printing can be accomplished in the home. Whether you want to create unique tee-shirts using a home screen printing machine or you want to produce elegant laser printed letters, the equipment is readily available to you for home use.



 


© 2006 articles2k.com - Privacy Policy