Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    May 2005
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    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.

  • #2
    Regular Coder
    Join Date
    May 2004
    Posts
    121
    Thanks
    0
    Thanked 0 Times in 0 Posts
    ..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?

  • #3
    New to the CF scene
    Join Date
    May 2005
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •