Go Back   CodingForums.com > :: Server side development > Apache configuration

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 07-20-2005, 02:32 AM   PM User | #16
smartcars
New to the CF scene

 
Join Date: Jul 2005
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
smartcars is an unknown quantity at this point
Thanks for the smart tips. I'll make the changes and let you know.
smartcars is offline   Reply With Quote
Old 07-20-2005, 12:17 PM   PM User | #17
smartcars
New to the CF scene

 
Join Date: Jul 2005
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
smartcars is an unknown quantity at this point
Hi Span,

Well I made the changes and after clearing cache/files/cookies (everything) it still will not work.

Current file copy is as follows (I removed the Error codes for now):

Code:
RewriteEngine On
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://(www\.)?allsmartcars\.com/ [NC]
RewriteCond %{REQUEST_URI} !^graphics/hotlinkedtheft\.gif [NC]
RewriteRule \.(jpeg|gif|bmp|png|jpg)$ http://www.allsmartcars.com/hotlinkedtheft.gif [R,L]
smartcars is offline   Reply With Quote
Old 07-20-2005, 02:03 PM   PM User | #18
Span
Regular Coder

 
Join Date: May 2004
Posts: 121
Thanks: 0
Thanked 0 Times in 0 Posts
Span is an unknown quantity at this point
Hi,

I wonder why it worked for me yesterday.. but I changed it a bit, the URL in the RewriteRule is a relative one now. This is a 'silent' internal rewrite. If that doesn't work, I don't know.

Code:
RewriteEngine On
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://(www\.)?allsmartcars\.com [NC]
RewriteCond %{REQUEST_URI} !^graphics/hotlinkedtheft\.gif [NC]
RewriteRule \.(jpeg|gif|bmp|png|jpg)$ /graphics/hotlinkedtheft.gif [L]
The only weak point from this or other no-hotlinking htaccess codes is that it doesn't work for user agents that hide the referer string or are behind some proxy or firewall.
Span is offline   Reply With Quote
Old 07-20-2005, 02:14 PM   PM User | #19
smartcars
New to the CF scene

 
Join Date: Jul 2005
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
smartcars is an unknown quantity at this point
Hi Span,

I just tried your re-write. I checked to view http://www.allsmartcars.com/gallery/...ize/001019.jpg at http://altlab.com/hotlinking.html and was able to view it. I chose that image because I know for sure I haven't viewed.

I'm at a loss.

Jim
smartcars is offline   Reply With Quote
Old 07-21-2005, 01:27 PM   PM User | #20
Span
Regular Coder

 
Join Date: May 2004
Posts: 121
Thanks: 0
Thanked 0 Times in 0 Posts
Span is an unknown quantity at this point
Jim, one last possible solution left.. try adding this:

Options +FollowSymLinks

as the first line of your .htaccess. Sometimes that is needed. It might also throw a 500 error or do nothing, but it's worth a try.
Span is offline   Reply With Quote
Old 07-26-2005, 06:29 PM   PM User | #21
darkannie
New Coder

 
Join Date: Mar 2003
Posts: 71
Thanks: 0
Thanked 0 Times in 0 Posts
darkannie is an unknown quantity at this point
Quote:
Originally Posted by Span
Since you can put all your stuff in one .htaccess there's never a need for two of them in the same directory, is there? And obviously - uploading the second one would simply overwrite the first.

You can add the code above to your existing .htaccess, but you have to allow hotlinking for the 'hotlink' image, so I added a condition:

RewriteEngine on
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://(www\.)?domain\.tld/ [NC]
RewriteCond %{REQUEST_URI} !^/path_to/nohotlinking\.jpg [NC]
RewriteRule \.(gif|jpg)$ http://www.domain.tld/path_to/nohotlinking.jpg [R,L]

If you don't want the redirect to an anti-hotlinking image, use this:

RewriteEngine on
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://(www\.)?domain\.tld/ [NC]
RewriteRule \.(gif|jpg)$ - [F]

That will simply serve a 403 Permission Denied.



I just have one question, and I'm an idiot, but I'm also a cautious idiot. I just want to be sure before I take that code and put it in the .htaccess file (since I found it, yay!), do I substitute the word domain for my own, or do I need to change anything else? Do I keep the .tld?
darkannie is offline   Reply With Quote
Old 07-26-2005, 06:35 PM   PM User | #22
Span
Regular Coder

 
Join Date: May 2004
Posts: 121
Thanks: 0
Thanked 0 Times in 0 Posts
Span is an unknown quantity at this point
Hi,

yes you have to replace "domain\.tld" with your own "darkannie\.net".

.tld is just short for Top Level Domain
Span is offline   Reply With Quote
Old 07-26-2005, 06:37 PM   PM User | #23
darkannie
New Coder

 
Join Date: Mar 2003
Posts: 71
Thanks: 0
Thanked 0 Times in 0 Posts
darkannie is an unknown quantity at this point
YAY! Ok, thank you.


[edit]

Yay, it worked. Not only do I spare my bandwidth from robbers, but I also have some free advertising! This rocks so hard. Thank you, everyone! Thank you, thank you, thank you!!!

Last edited by darkannie; 07-26-2005 at 06:52 PM..
darkannie is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 08:27 PM.


Advertisement
Log in to turn off these ads.