PDA

View Full Version : Remove 1 image from htaccess protection


Roni20
2005-06-22, 02:13 PM
Hi

I want to remove 1 image from some folder from htaccess protection, how to do this?

regards
roni

Leon
2005-06-22, 05:15 PM
well for example if you using something like:
RewriteEngine on
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?yoursite.com.*$ [NC]
RewriteRule ^.+\.(jpg|jpeg|png|gif)$ - [NC,F,L]

i belive all you will need to is to add this:
RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?yoursite.com/images/mypic.gif.*$ [NC]

Roni20
2005-06-22, 06:33 PM
Doesn't work :(

cd34
2005-06-22, 06:37 PM
RewriteEngine on
RewriteRule ^image_to_allow_hotlinking.jpg$ - [L]

RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?yoursite.com.*$ [NC]
RewriteRule (jpg|jpeg|png|gif)$ - [F,L]

Roni20
2005-06-23, 03:20 AM
Doesn't work too :(

Leon
2005-06-23, 03:48 AM
hmm intresting , what you can do is to put the .htaccess directly in /images/ folder and the image you dont wont be protected to put outside of /images/ folder
that will defenetly work ;)

cd34
2005-06-23, 04:10 AM
If your /hotlinkable/ directory is below the directory that you have protected, make sure you put

RewriteEngine off


in your .htaccess

Roni20
2005-06-23, 05:53 AM
If i have :

RewriteEngine on
RewriteRule ^domain.com/dir/dir/dir/image.jpg$ - [L]

RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?domain.com.*$ [NC]
RewriteRule (jpg|jpeg|png|gif)$ - [F,L]

it doesn't work, all images are protected

---------
if:

RewriteEngine on

RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?domain.com.*$ [NC]
RewriteRule (jpg|jpeg|png|gif)$ - [F,L]

RewriteEngine off
RewriteRule ^domain.com/dir/dir/dir/image.jpg$ - [L]

than all images are able to hotlink the same with

RewriteEngine off

RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?domain.com.*$ [NC]
RewriteRule (jpg|jpeg|png|gif)$ - [F,L]

RewriteRule ^domain.com/dir/dir/dir/image.jpg$ - [L]

:(

Anothers
2005-06-23, 01:55 PM
If i have :

RewriteEngine on
RewriteRule ^domain.com/dir/dir/dir/image.jpg$ - [L]

RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?domain.com.*$ [NC]
RewriteRule (jpg|jpeg|png|gif)$ - [F,L]


hmm

let's suppose this image is
http://www.domain.com/images/image.jpg

then this should work

RewriteEngine on

RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?domain.com.*$ [NC]
RewriteCond %{REQUEST_URI} !^/images/image.jpg$
RewriteRule (jpg|jpeg|png|gif)$ - [F,L]

Edited: RewriteEngine off - turns off all rewrite engine so anything like RewriteCond or RewriteRule doesnt work when is below RewriteEngine off

cd34
2005-06-23, 03:03 PM
If http://www.domain.com/ is protected
If you want to serve http://www.domain.com/image.jpg and allow hotlinking

RewriteEngine on
RewriteRule ^image.jpg$ - [L]

RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?domain.com.*$ [NC]
RewriteRule (jpg|jpeg|png|gif)$ - [F,L]

If http://www.domain.com/ is protected
If you want to serve anything in http://www.domain.com/image/ and allow hotlinking

put this in your main .htaccess in the root of http://domain.com/
RewriteEngine on
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?domain.com.*$ [NC]
RewriteRule (jpg|jpeg|png|gif)$ - [F,L]

and in the image directory put the following in .htaccess
RewriteEngine off

Roni20
2005-06-23, 04:27 PM
ok thanks guys, now is ok :)