Stop People From Hotlinking Your Images - PHP / MySQL Tutorials
 
  Buy Ebooks, Video Games, DVDs, Electronics and more !
Home | Help Forums | Web Design Tutorials | Free Swishmax Downloads Make Money Online Blog . Free Image and Photo Sharing and Hosting

 

 

Company

Home

Nework Details

Tutorials

SWiSH 2

SWiSHMax

Flash MX

PHP & MySQL

HTML / JScript

Adobe Photoshop

Corel Draw

Gimp

Miscellaneous

Downloads

Templates

Plugins

Fonts

Wallpapers

Free Images

Scripts and Codes

Products

E-Books

SWiSH BB

SWiSH Templates

SWiSH-DB Newsletter
Subscribe to our newsletter : GO
  Partners / Affiliates

   Free image hosting
   Web Design Pakistan
   Swish Templates
   SWiSH Climax
   Talkfreelance Community
   Template Desire
   Lite boards
   Script Sector
   GimpTalk
   13dots
   Idea Designs
   PHP Cafe
   Sposatoettore
   Free swishmax templates
   Swishzone

Manage your site with Flax Article Content Management System
Stop People From Hotlinking Your Images
Category : PHP / MySQL | Level : Beginner | Language : English
Ask Question | Read Comments | Post tutorial | Previous | Next

Web www.swish-db.com

I came across on one of the blogs i read and thought it would be quite handy to some of you.

From Scriptygoddess.com


How to's: Protect your images with .htaccess

.htaccess files are lovely, lovely things. They do exactly what the name implies: control access to your files. About six months ago, I had problems with a bunch of l33t brats 'borrowing' my bandwidth and using a few of my photos on message boards.

So I decided to take their toy away.

A lovely thing about .htaccess files: if you place them in a directory, the conditions and permissions you set up affect all subfolders of that folder. So, if you want to protect all your images, just drop a single .htaccess file in your main images directory, and all subfolders are taken care of.

Here's the code that I'm using for my .htaccess file:

RewriteEngine onRewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://YOURSITE.COM/.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http://WWW.YOURSITE.COM/.*$ [NC]ReWriteRule .*\.(gif|jpg)$ - [N,F,L]

It's a good idea to do both yoursite.com and www.yoursite.com. Also, if you know of any other sites that you want to allow to use your images, be sure to add in a line for them in this file.

If the http_referer doesn't match one of the strings you've provided in those lines, the image request will result in a 403 error.

To use this code on your site...

Make sure you can see hidden files (files beginning with a .) with your FTP client. (It's really hard to edit or delete files you can't see.) Paste these lines into a blank text document, save it as .htaccess, and upload it to your images directory.

That should be all!



© 2002-2005 Flaxweb Network | Article Manager | Gimp Tutorials Library | RAD C++ Library | Free C/C++ Sourcecode |
Sites of interest : Web Design Blog | Swish Templates | Swishmax Ebook | Photoshop Templates | Gimp Tutorials | Text Forum | Make Money Online