Welcome to WebmasterWorld Guest from 54.159.250.110

Forum Moderators: Ocean10000 & incrediBILL & phranque

Message Too Old, No Replies

Allow and Deny hotlinking code question

Allow and Deny hotlinking code question

   
2:17 pm on Jan 14, 2004 (gmt 0)

10+ Year Member



i have created a .htaccess file in my public web folder wish avoid other sites from hotlinking images from any of the folders on my server .

RewriteEngine on
# redirect images
RewriteCond %{HTTP_REFERER}!^$
RewriteCond %{HTTP_REFERER}!^http://(www\.)?example\.com/ [NC]
RewriteRule \.(gif?jpe?g?)$ /no.$1 [NC,L]

This works well.

Now my question is i want to allow hotlinking from one folder with few banners now what new .htaccess do i have to make so that hotlinking is allowed from this folder only and all others are protected.

this is my server

var/home/web/htdocs/ .htaccess with anti hotlink code
var/home/web/htdocs/images/ this is auto protected by above htaccess file
var/home/web/htdocs/faq/icons/ this one is protected to ..

now i made a folder at:
var/home/web/htdocs/faq/icons/protect/

now what sort .htaccess file do i have to put inside the folder /protect/ to allow hotlinking from this folder only so i can put some banners inhere ....

pls advise

[edited by: DaveAtIFG at 4:52 pm (utc) on Jan. 14, 2004]
[edit reason] Revised URL pattern to "example" [/edit]

6:47 pm on Jan 14, 2004 (gmt 0)

WebmasterWorld Senior Member jdmorgan is a WebmasterWorld Top Contributor of All Time 10+ Year Member



stopspam,

Simply add another RewriteCond to your existing code in /htdocs:


RewriteEngine on
# redirect images except banners
[b]RewriteCond %{REQUEST_URI} !^/faq/icons/protect/[/b]
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://(www\.)?example\.com/ [NC]
RewriteRule \.(gif¦jpe?g?)$ /no.$1 [NC,L]

Jim
7:25 pm on Jan 14, 2004 (gmt 0)

10+ Year Member



Hi Jim thanks for your reply ..

can you give me more details on what;
RewriteCond %{REQUEST_URI}!^/faq/icons/protect/

ecactly will do?

will it exclute this fodler protect or will it only stop hotlinking in folder protect?

what i need is that all folders are antihotlink protected ecept from one folder ...

7:21 pm on Jan 15, 2004 (gmt 0)

WebmasterWorld Senior Member jdmorgan is a WebmasterWorld Top Contributor of All Time 10+ Year Member



It stops the following RewriteRule from being applied if the image is in that /faq/icons/protect/ directory. Hopefully, it will do what you want to do! ;)

Jim

10:26 pm on Jan 15, 2004 (gmt 0)

10+ Year Member



excellent i go play with the code and test ..
i will et you knwo if worked ..

thx ;)