Main Menu




browser lang:en

Users Area

Client Login

today cache size is:222615

 

Holyguard rss
rss 2.0 for all sections

 

Portfolio

Some of my projects:
CTIBA
MA-NO Web Agency
BluPool
L'Pratone
Travel in Hotel
Yacht Elements
AbruzzoWeb
Il Mastino
CSI Teramo
Innovazione S.p.a.




Comments

John
24/07/2010 by John
better
16/04/2010 by bob
attached files not working !
05/11/2009 by Adnan
Tuvok
14/02/2009 by
Nice script
07/02/2009 by desaj
Other solutions
07/02/2009 by Mike
well
06/02/2009 by holy
Theif
06/02/2009 by

Read More »


RAPIDQ

Rapid-Q:The lost files
My old library where i have collected all the rapidq scripts and italian help


Today my pagerank is: Free Page Rank Tool

Apache:how to prevent hotlinking

Apache Rewrite Module

The mod_rewrite Apache module is one of the best tools you can have on your server to help prevent unauthorized sites "hotlinking" your images or other files. Providing that your server has been set up for it, you can use this module for a number of things.

    * To prevent unauthorised use of files and images
    * To hide the real location of files on the server
    * To translate script input from one format to another
    * To redirect the user based on...
          o time of day
          o file they accessed
          o network they are connecting from
          o or anything else that can identify them as part of a "group" of users

Preventing Hotlinking

The most common use of the RewriteEngine is to limit access to specific file types on the server. To do this, you will need to add some rules and conditions to your .htaccess file so that the server knows what to look for and what to do when it finds requests that don't meet the criteria.

When editing your .htaccess file it is recommended that you use Notepad or equivalant to keep the file clean. Remember to upload the file in ASCII mode!

Here is a generic version of the code you will want to use. Of course you will need to make changes before it will work the way you want it to; replace all instances of you.com with your own domain name and add or remove file types as you see fit.

Rewriteengine on
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://your_domain.com/.*$ "NC"
RewriteCond %{HTTP_REFERER} !^http://www.your_domain.com/.*$ "NC"
RewriteCond %{HTTP_REFERER} !^http://www.trusted.com/.*$ "NC"
RewriteRule .*\.(gif|GIF|jpg|JPG)$ - "F"
How does it Work?

It's all very well having the code, but you may be interested to know how it works so that you can have a go at editing it to behave more like you want it to. If you ever want to disable the rules, it is much better to use the Rewriteengine statement to switch them off as opposed to commenting them out or deleting them from your file.

The RewriteCond lines tells the server to look for requests with HTTP_REFERER strings that are not empty and that match valid uses of your domain as you define them in the file.

The ! at the start of the condition pattern means not, and so negates the result of the pattern that follows it. ^ and $ are special characters used to match the start and the end of the string in question. So the pattern ^http:// would look for strings starting in http:// and gif$ would match strings ending in gif. The sequence .* will match any character for 0 or more times, and so adding it to the start or end of a particular string will allow fuzzy pattern matching of sorts.

The "NC" flag at the end of the RewriteCond lines tells the server to ignore the case (no case) while looking for matches.

The RewriteRule line tells the server how to deal with the requests that match the condition. In this case it is looking for requests to image files that end in .gif or .jpg (either in all capital letters or all lower case, the options to match are shown in brackets separated by the | character). Note that the . has to be un-escaped by adding a \ in front of it as it is the special character that denotes other characters.

When it finds a request that has passed all the conditions and matches the rule, it will rewrite the request with -, although this could just as easily go to a page on your site. Finally the "F" flag tells the server how to respond to the request, in this particular case, it will tell the browser that it is forbidden from retrieving that file.

Rating:
73.0
6 votes
1 2 3 4 5

Comments

Insert your comment

Titolo
Messaggio
Nome Utente
e-mail (se vuoi ricevere le risposte a questo post anche via mail)

Videos


Contents

Selective Tweets Application for Facebook

21/07/2010 

Selective Tweets is an application that allows you to control what tweets are added to your Facebook…

in:Social Networking (0 comments)

FBJS Quick Jump Menu for a FBML Facebook Platform App

15/07/2010 

In a FBML Facebook App, your quick jump menu will require a little tweak to work in FBJS…

in:Scripts and tutorials (0 comments)

How to manage your online reputation, free tools forcommunity managers

02/07/2010 

Every single day, someone, somewhere is discussing something important to your business; your brand, your executives, your…

in:Scripts and tutorials (0 comments)

Genuitec MobiOne Enables Developers to Create Web Apps for the iPhone

28/05/2010 

Although some IT managers are coming around to the idea of supporting iPhones, most aren’t convinced…

in:Free Software (0 comments)

How to configure MX records for incoming SMTP e-mail traffic

27/03/2010 

When you want to run your own mail server, and it does not matter what version and…

in:Apache - .htaccess (0 comments)

Complete guide for Jquery Developers

27/02/2010 

Have you ever had to develop something yourself only to find out that there had already been…

in:JQuery (0 comments)

How can i insert HTML code in my posts?

14/02/2010 

The situation begins with your blog or website and you need to post some code on a particular…

in:The Holy Faq's (0 comments)

12 undocumented tricks for Google Buzz

14/02/2010 

So. Google just recently announced Google Buzz. I’m not sure about you, but I…

in:Blog (0 comments)

Read more »


Tag Clouds


Selective Tweets Application FacebookFBJS Quick Jump Menu FBML Facebook Platform AppHow manage your online reputation free tools forcommunity managersGenuitec MobiOne Enables Developers Create Apps iPhoneHow configure records incoming SMTP email


Add to Technorati Favorites