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 5 of 5
  1. #1
    New to the CF scene
    Join Date
    Feb 2003
    Location
    Norway
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    htaccess - Hot linking

    I read the tutorial at javascriptkit.com on how to prevent hot linking, I used this code:

    RewriteEngine on
    RewriteCond %{HTTP_REFERER} !^$
    RewriteCond %{HTTP_REFERER} !^http://(www\.)?mydomain.com/.*$ [NC]
    RewriteRule \.(gif|jpg)$ http://www.mydomain.com/nasty.gif [R,L]

    but I can't even see the pictures on my own server when using this code, so what do I need to add here to make it work?

    Thanks in advance
    Blackhat

  • #2
    New to the CF scene
    Join Date
    Feb 2003
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Did you replace "mydomain.com" with your own domain name?

    ie, "YourDomainName.com"

    Also, I had to put in two lines, since I can be accessed with or without the "www."

    Mine reads;
    RewriteCond %{HTTP_REFERER} !^http://?michaelsplace.us/.*$ [NC]
    RewriteCond %{HTTP_REFERER} !^http://(www\.)?michaelsplace.us/.*$ [NC]

    (although that's what I was told. I didn't try with just one line)
    MLReynolds

  • #3
    Regular Coder Feyd's Avatar
    Join Date
    May 2002
    Location
    Los Angeles, CA Maxim: Subvert Society
    Posts
    404
    Thanks
    0
    Thanked 0 Times in 0 Posts
    You don't need to use two different lines to specify www and non-www, MLR...try this instead:

    Code:
    RewriteCond %{HTTP_REFERER} !^http://([a-z0-9-]+\.)*yourdomain.*$ [NC]
    That will pretty much match everything you need it to (www vs. non-www, virtual domains, different domain identifiers, etc.)
    Moderator, Perl/CGI Forum
    shadowstorm.net - subvert society

  • #4
    New to the CF scene
    Join Date
    Feb 2003
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thank you for the tip. I still have a problem with Google's cache files displaying properly. Text only displays. Not images or formatting.

    Any Idea?
    MLReynolds

  • #5
    New Coder dragon's Avatar
    Join Date
    May 2003
    Location
    Florida
    Posts
    99
    Thanks
    0
    Thanked 0 Times in 0 Posts
    On a similar note, I'm trying to set up htaccess to prevent hotlinking but allow images to be viewed from multiple locations, my primary website and a forum hosted by someone else. The forum is at http://users.boardnation.com/~dragon76n/ so here's what I used:
    Code:
    RewriteEngine on
    RewriteCond %{HTTP_REFERER} !^$
    RewriteCond %{HTTP_REFERER} !^http://(www\.)?dragonshobbies.com/.*$ [NC]
    RewriteCond %{HTTP_REFERER} !^http://(users\.)?boardnation.com/~dragon76n/.*$ [NC]
    RewriteRule \.(gif|jpg)$ http://www.dragonshobbies.com/dhminilogo.gif [R,L]
    The problem was that it would still display my dhminilogo.gif on my forum.

    Should I write out the address completely, instead of having users\. in parenthisis? (I just thought of this so I haven't had a chance to test it yet.) Or what should I do?

    UPDATE:

    Code:
    RewriteCond %{HTTP_REFERER} !^http://users.boardnation.com/~dragon76n/.*$ [NC]
    This code did work to allow my forum to get the images. I ended up putting it into the images folder though, instead of in the root folder.
    Last edited by dragon; 05-19-2003 at 07:06 AM.


  •  

    Posting Permissions

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