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 6 of 6
  1. #1
    New Coder
    Join Date
    Apr 2004
    Posts
    19
    Thanks
    0
    Thanked 0 Times in 0 Posts

    .htaccess problem

    I wrote this script to disable hotlinking and I can't get it to work. Anyone know how I can make this work ?

    PHP Code:
    <Files .htaccess>
    order allow,deny
    deny from all
    RewriteEngine on RewriteCond 
    %{HTTP_REFERER} !^$
    RewriteCond %{HTTP_REFERER} !^http://(www\.)?project-angel.com/.*$ [NC]
    RewriteRule .(jpe?g|gif|bmp|png)$ images/htaccess/hotlink.jpg [L]
    </
    Files
    :|

  • #2
    New Coder
    Join Date
    Apr 2004
    Posts
    19
    Thanks
    0
    Thanked 0 Times in 0 Posts
    anyone?

  • #3
    Senior Coder gsnedders's Avatar
    Join Date
    Jan 2004
    Posts
    2,340
    Thanks
    1
    Thanked 7 Times in 7 Posts
    PHP Code:
    Options +FollowSymlinks
    RewriteCond 
    %{HTTP_REFERER} !^http://(www\.)?project-angel.com(/)?.*$     [NC]
    RewriteRule .*.(jpeg|gif|bmp|png|jpg)$ [url]http://www.project-angel.com/images/htaccess/hotlink.jpg[/url] [R,NC] 

  • #4
    New Coder
    Join Date
    Apr 2004
    Posts
    19
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I assume this would go after my <files .htaccess> tag ? is there anything else I need ?

  • #5
    Senior Coder gsnedders's Avatar
    Join Date
    Jan 2004
    Posts
    2,340
    Thanks
    1
    Thanked 7 Times in 7 Posts
    Where did you get that <files .htaccess> tag? You just put exactly what I said in the .htaccess, no more, no less.

  • #6
    Regular Coder
    Join Date
    May 2004
    Posts
    121
    Thanks
    0
    Thanked 0 Times in 0 Posts
    ..no more, no less.
    Well.. you have to turn it on first, exclude the hotlink image to allow it being hotlinked to, exclude blank referrers, escape the dots and you don't need the (/)?.*$ at the end of the RewriteCond.
    In the RewriteRule, again, you have to escape the second dot (to actually match a dot instead of 'any character') and you don't need the NC flag at the end.

    Code:
    Options +FollowSymlinks
    RewriteEngine On
    RewriteCond %{HTTP_REFERER} !^$
    RewriteCond %{REQUEST_URI} !^/images/htaccess/hotlink\.jpg [NC]
    RewriteCond %{HTTP_REFERER} !^http://(www\.)?project-angel\.com [NC]
    RewriteRule .*\.(jpeg|gif|bmp|png|jpg)$ http://www.project-angel.com/images/...ss/hotlink.jpg [R,L]
    Last edited by Span; 09-07-2004 at 12:19 PM. Reason: Added "allow blank referrer" for users behind firewalls, etc..


  •  

    Posting Permissions

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