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 05-20-2005, 03:25 PM   PM User | #1
robertdfeinman
New to the CF scene

 
Join Date: May 2005
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
robertdfeinman is an unknown quantity at this point
strange htaccess behavior

'm trying to block hotlinking of images from just some particular domains.
I've created a .htaccess file as shown below. Some times this seems to work, and sometimes it doesn't. I'm baffled by the inconsistent results.

Here are two successive lines from the log file (wrapped for clarity).
In the first case the image is blocked, but in the second it's not.
I've also had the condition where the image is blocked for one request, but not for a subsequent one from the same site.
Notice the first entry returns a 304 status as expected, but the second yields a 200 and delivers the image even though the domain is the same for both.

Any ideas what's going on?

log file:
------- first request
66.XXXX - - [19/May/2005:10:28:49 -0400]
"GET /panoramic_horizontal/hawaii/maui/images/maui_sunset_hpan.jpg
HTTP/1.1" 304 - "http://www.xanga.com/home.aspx?user=lisalyn"
"Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.8)
Gecko/20050511 Firefox/1.0.4"
-------second request
66.XXXX - - [19/May/2005:10:29:16 -0400]
"GET /panoramic_horizontal/scenic/images/sunset_over_water2.jpg
HTTP/1.1" 200 36747 http://www.xanga.com/home.aspx?user=MILESmayLIEbetweenUS"
"Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.8)
Gecko/20050511 Firefox/1.0.4"

---- .htaccess file:

RewriteEngine On
RewriteCond %{HTTP_REFERER} ^http://(www\.)?xanga\.com/ [NC,OR]
RewriteCond %{HTTP_REFERER} ^http://(www\.)?myspace\.com/ [NC]
RewriteRule \.(jpe?g|gif|bmp|png)$ - [F,L]
---------
Thanks in advance for any suggestions.
robertdfeinman is offline   Reply With Quote
Old 05-22-2005, 01:36 PM   PM User | #2
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
Quote:
..the first entry returns a 304 status as expected..
Hi,

both requests should have been served a 403 Forbidden, not a 304 Not Modified or 200 OK. So your code doesn't work at all, or have you seen 403s in your logs?
I'm not seeing any errors in your code though, except for the "L" flag, which is not needed when you use [F]. You could try your code with only the [F] flag but I don't think it will make a difference.
Are there other rewrites in your htaccess? Ones that work? Does your host support mod rewrite?
Span is offline   Reply With Quote
Old 05-22-2005, 03:16 PM   PM User | #3
robertdfeinman
New to the CF scene

 
Join Date: May 2005
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
robertdfeinman is an unknown quantity at this point
Thanks for taking the time to look at my example.

I have subsequently figured out what you surmised, that the htaccess
file is not be read at all.
I put the code into the main conf file and it works fine.
I don't know if the version of Apache is too old or if there is some directive
missing in the main conf file to activate the htaccess feature.

So right now it just a minor inconvenience when the code needs to be modified.
robertdfeinman 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:48 AM.


Advertisement
Log in to turn off these ads.