Welcome to WebmasterWorld Guest from 54.144.243.34

Forum Moderators: Ocean10000 & incrediBILL & phranque

.htaccess to prevent hot linking help

   
11:54 am on Jul 30, 2003 (gmt 0)

10+ Year Member



Hi, newbie here!

Sorry, I'm sure this has come up many times before, but I've not been able to find an answer to my problems!

I've recently discovered htaccess and want to use it to stop bandwidth thieves.
My web host doesn't support mod rewrite, so I've being trying to use this code from snip:

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
<FilesMatch "\.(gif¦png¦jpe?g)$">
Order Allow,Deny Allow from env=locally_linked
</FilesMatch>

with snip for your-domain-name-here.com

I've saved this code in a .htaccess file, uploaded it in ascii mode to a subfolder in my site directory.

It works, but too well. Everyone is denied permission to view the images, even when viewing them from my website.

Can anyone help me sort out this problem, so that I can view the images on my own pages, please?

link to my test page:
snip

TIA!

Sam

[edited by: DaveAtIFG at 12:45 pm (utc) on July 30, 2003]
[edit reason] No specifics please [/edit]

2:07 am on Aug 1, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Welcome to WebmasterWorld feralc! We're not ignoring you. Honest! :)

The logic in your rules seems sound to me (but I'm no expert!) Try changing from:

Order Allow,Deny Allow from env=locally_linked

to:
Order Allow,Deny
Allow from env=locally_linked

The Apache docs [httpd.apache.org] are pretty specific about the format of the first line. "Keywords may only be separated by a comma; no whitespace is allowed between them," yet I see nothing about the format of subsequent lines. However all of the examples I've seen delimit each line within a <FilesMatch> directive with a "new line."

Give it a try and let us know. And perhaps someone that knows what they're doing will join the thread! :)

11:38 am on Aug 1, 2003 (gmt 0)

10+ Year Member



Thanks for your suggestion. :)
Unfortunately it seems to have made no difference.

I'm guessing the problem is something to do with how the allowed referrers are specified, maybe.

If I have the .htaccess file in domain.co.uk/abc/xyz (for example) should the referrer be domain.co.uk or maybe
domain.co.uk/abc/xyz?

Sam

5:33 pm on Aug 1, 2003 (gmt 0)

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



Maybe try a simplified version:

SetEnvIfNoCase Referer "^http://(www\.)?your-domain-name-here\.com" locally_linked
SetEnvIf Referer "^$" locally_linked
<FilesMatch "\.(gif¦png¦jpe?g)$">
Order Allow,Deny
Allow from env=locally_linked
</FilesMatch>

Jim
 

Featured Threads

My Threads

Hot Threads This Week

Hot Threads This Month