Code behind the protection (.htaccess) Hotlink protection

Problem:

I need to protect the /images folder to not show images when people type in the correct URL like www.mydomain.com/images/

Solution:

Using hotlink protection.... Oh you want more?
How to protect your images from prying eyes

Hotlink protection, Password protecting, or chmod could help you, this can be done several ways the way you should protect a directory of files or images. Apache has a built-in method for protecting images with in directories from prying eyes, using the .htaccess file.

When your browser sends a request for an image, it usually also sends the URL of the page that linked to that image. The following .htaccess file causes the server to check this URL ("Referer" in the following snippet) and if it is one of the authorized URLs that you specify, it will set an internal flag called "locally_linked". This internal flag is technically called an "environmental variable". If the URL sent is not in this list of authorized URLs, the flag (or ev) is not set. Note that we also set the "locally_linked" variable if the browser does not send any URL at all: this occurs when the visitor accesses your site using a browser or a proxy that suppresses the referring URL.

The web server then checks if the file requested has an extension in the list given below (gif, png, jpg and jpeg). If so, and the "locally_linked" variable is set, it will send the image. Otherwise it an error will be sent. If this is to complex then you can use the hotlink manager, or the password protect icon in the cpanel.

---------------code-----------------------------------------------------------
SetEnvIfNoCase Referer "^http://www.your-domain-name-here.com/" locally_linked=1
SetEnvIfNoCase Referer "^http://www.your-domain-name-here.com$" locally_linked=1
SetEnvIfNoCase Referer "^http://your-domain-name-here.com/" locally_linked=1
SetEnvIfNoCase Referer "^http://your-domain-name-here.com$" locally_linked=1
SetEnvIfNoCase Referer "^$" locally_linked=1

Order Allow,Deny
Allow from env=locally_linked

Var dette svaret til hjelp? 0 brukere syntes dette svaret var til hjelp (0 Stemmer)