homepage Welcome to WebmasterWorld Guest from 23.20.77.156
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Pubcon Platinum Sponsor 2014
Home / Forums Index / Code, Content, and Presentation / Apache Web Server
Forum Library, Charter, Moderators: Ocean10000 & incrediBILL & phranque

Apache Web Server Forum

    
.htaccess to prevent hot linking help
feralc




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

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]

 

DaveAtIFG




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

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! :)

feralc




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

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

jdMorgan




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

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

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / Apache Web Server
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved