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 9 of 9
  1. #1
    New to the CF scene
    Join Date
    Jan 2003
    Location
    Spokane WA
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    I need help with htaccess

    Ever since I put videos and mp3s on my site lots of other sites have linked them which in turn uses up my bandwidth. I was told by my host that I could block access from certain ips or urls by adding

    order allow,deny
    deny from www.korni.by.ru
    deny from www.geocities.com/kornheavymetalenglish
    allow from all

    to my .htaccess file. When I did that I went to the sites that should have been blocked from my site and I was still able to download my videos and mp3s that they had linked off of my site. Please help me I can't afford to have these people using up all my bandwidth.

  • #2
    jkd
    jkd is offline
    Senior Coder jkd's Avatar
    Join Date
    May 2002
    Location
    metro DC
    Posts
    3,163
    Thanks
    1
    Thanked 18 Times in 18 Posts

  • #3
    New to the CF scene
    Join Date
    Jan 2003
    Location
    Spokane WA
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I also tried putting the below in my .htaccess but that also did not work.

    RewriteEngine on
    RewriteCond %{HTTP_REFERER} !^$
    RewriteCond %{HTTP_REFERER} !^http://(www\.kornhead.net/.*$ [NC]
    RewriteRule \.(mp3|jpg)$ - [F]

  • #4
    jkd
    jkd is offline
    Senior Coder jkd's Avatar
    Join Date
    May 2002
    Location
    metro DC
    Posts
    3,163
    Thanks
    1
    Thanked 18 Times in 18 Posts

    Re: I need help with htaccess

    Ok, I'm no .htaccess expert, but shouldn't something like:

    order deny,allow
    allow from www.kornhead.ne
    deny from all

    work?

  • #5
    New to the CF scene
    Join Date
    Jan 2003
    Location
    Spokane WA
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Didn't work. It blocked everyone.

  • #6
    Supreme Overlord Spookster's Avatar
    Join Date
    May 2002
    Location
    Marion, IA USA
    Posts
    6,273
    Thanks
    4
    Thanked 83 Times in 82 Posts
    Dont waste your time doing it with htacess. In order to protect the files you have to use HTTP_REFERRER however that information is given to the server from the users browser. Not all browsers give that information or give it correctly or allow people to change it.

    Put the files in a non-web accessible directory and store the paths in a database then in the pages the links for the files will run through the database which you can then control and people can't hotlink.
    Spookster
    CodingForums Supreme Overlord
    All Hail Spookster

  • #7
    New to the CF scene
    Join Date
    Jan 2003
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I have been having a similar problem with my .htaccess file. I also want to disable hotlinking, for which I used the following code:

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

    When I use this though (which I believe is written correctly) my server then blocks my own domain as well. Hence, none of the images on my site work if I try and disable hotlinking. I contacted the support people at my server, and they just told me that their system randomly rewrites htaccess files. Is that normal?

    I would like to know more about protecting files by putting them in a non-web accessible folder, as states below:

    "Put the files in a non-web accessible directory and store the paths in a database then in the pages the links for the files will run through the database which you can then control and people can't hotlink."

    Im guessing this is some form of PHP script? Or? If someone could post a tutorial link for how to accomplish this that would be great. The tutorial would have to be rather detailed though since I have no idea how to write PHP.

    Any help is appreciated. Much as I ask people not to direct link to media on my site, everyone does!

  • #8
    Regular Coder
    Join Date
    Jun 2002
    Location
    Canada
    Posts
    254
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: I need help with htaccess

    Originally posted by kornhead

    order allow,deny
    deny from www.korni.by.ru
    deny from www.geocities.com/kornheavymetalenglish
    allow from all
    Try taking off the www part (leaving the first period though).

    order allow,deny
    deny from .korni.by.ru
    deny from .geocities.com/kornheavymetalenglish
    allow from all

  • #9
    Regular Coder
    Join Date
    Jun 2002
    Location
    Canada
    Posts
    254
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Originally posted by kornhead
    I also tried putting the below in my .htaccess but that also did not work.

    RewriteEngine on
    RewriteCond %{HTTP_REFERER} !^$
    RewriteCond %{HTTP_REFERER} !^http://(www\.kornhead.net/.*$ [NC]
    RewriteRule \.(mp3|jpg)$ - [F]
    You have to find out from your web host if they support mod_rewrite. Some hosts do not and thus this attempt would fail.


  •  

    Posting Permissions

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