Greenguy's Board

Greenguy's Board (http://www.greenguysboard.com/board/index.php)
-   Programming & Scripting (http://www.greenguysboard.com/board/forumdisplay.php?f=15)
-   -   Remove 1 image from htaccess protection (http://www.greenguysboard.com/board/showthread.php?t=21167)

Roni20 2005-06-22 01:13 PM

Remove 1 image from htaccess protection
 
Hi

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

regards
roni

Leon 2005-06-22 04: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 05:33 PM

Doesn't work :(

cd34 2005-06-22 05: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 02:20 AM

Doesn't work too :(

Leon 2005-06-23 02: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 03: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 04: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 12:55 PM

Quote:

Originally Posted by Roni20
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 02: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 03:27 PM

ok thanks guys, now is ok :)


All times are GMT -4. The time now is 12:06 AM.

Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
© Greenguy Marketing Inc