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 7 of 7
  1. #1
    New to the CF scene
    Join Date
    Aug 2006
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    htaccess hotlinking problem

    Can anyone help, I have a site with a lot of WMV, MPEG, DCR and SWF files which I am trying to stop from being hotlinked.

    I have a Linux based shared hosting account on Godaddy

    This is .htacess file I have placed in my root but I have tried hotlinking it from another domain and works every time

    This is the code I am using

    Code:
    RewriteEngine on
    RewriteCond %{HTTP_REFERER} !^$
    RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?mydomain.co.uk [NC]
    RewriteRule \.(jpg|jpeg|png|gif|wmv|avi|gif|swf|dcr|mpeg|mpg)$ - [NC,F,L]
    Anyone have any ideas where I am going wrong or why its not working
    Really appreciate any advice
    Remo

  • #2
    Supreme Master coder! _Aerospace_Eng_'s Avatar
    Join Date
    Dec 2004
    Location
    In a place far, far away...
    Posts
    19,291
    Thanks
    2
    Thanked 1,043 Times in 1,019 Posts
    This is what I use
    Code:
    RewriteEngine on
    RewriteCond %{HTTP_REFERER} !^http://yoursite.com/.*$      [NC]
    RewriteCond %{HTTP_REFERER} !^http://yoursite.com$      [NC]
    RewriteCond %{HTTP_REFERER} !^http://www.yoursite.com/.*$      [NC]
    RewriteCond %{HTTP_REFERER} !^http://www.yoursite.com$      [NC]
    RewriteRule .*\.(jpg|jpeg|gif|png|bmp|wmv)$ - [F,NC]
    And it seems to work quite well.
    ||||If you are getting paid to do a job, don't ask for help on it!||||

  • #3
    New to the CF scene
    Join Date
    Aug 2006
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts
    will give it a try and wait for the server refresh

    Thanks for replying!

  • #4
    New to the CF scene
    Join Date
    Aug 2006
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Have got it to work for images but does not work for wmv files and the only part of the code i edited was for my domain name

    Any suggestions?
    Last edited by remo; 09-16-2006 at 08:15 AM.

  • #5
    Supreme Master coder! _Aerospace_Eng_'s Avatar
    Join Date
    Dec 2004
    Location
    In a place far, far away...
    Posts
    19,291
    Thanks
    2
    Thanked 1,043 Times in 1,019 Posts
    Hmm I've tried it with other extensions as well and it seems to work. It should only happen when a direct call to the file is made, something like
    http://www.yoursite.com/somefile.wmv this should return a 403 Forbidden error. Not sure why its not working for you, maybe you've messed something up? Can you post the htaccess you are using now?
    ||||If you are getting paid to do a job, don't ask for help on it!||||

  • #6
    New to the CF scene
    Join Date
    Aug 2006
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Just used what you provided

    Code:
    RewriteEngine on
    RewriteCond %{HTTP_REFERER} !^http://mysite.co.uk/.*$      [NC]
    RewriteCond %{HTTP_REFERER} !^http://mysite.co.uk$      [NC]
    RewriteCond %{HTTP_REFERER} !^http://mysite.co.uk/.*$      [NC]
    RewriteCond %{HTTP_REFERER} !^http://mysite.co.uk$      [NC]
    RewriteRule .*\.(jpg|jpeg|gif|png|bmp|wmv)$ - [F,NC]
    Were moving to a new site design next week and also need to be sure we can stop hotlinking from swf, avi, dcr, mpeg etc... as were moving to a new design we have to amend every page so was thinking might just be best to encypt the code for all the players and game files and in the process change the names of the worst affected files, painful to do but will probably offer best protection.

    Some of the files which people enjoy the most hotlinking are 20MBs + s so as can you imagine lots of bandwidth pressure

  • #7
    Supreme Master coder! _Aerospace_Eng_'s Avatar
    Join Date
    Dec 2004
    Location
    In a place far, far away...
    Posts
    19,291
    Thanks
    2
    Thanked 1,043 Times in 1,019 Posts
    You didn't look carefully. You need to use the www. url as well
    Code:
    RewriteEngine on
    RewriteCond %{HTTP_REFERER} !^http://mysite.co.uk/.*$      [NC]
    RewriteCond %{HTTP_REFERER} !^http://mysite.co.uk$      [NC]
    RewriteCond %{HTTP_REFERER} !^http://www.mysite.co.uk/.*$      [NC]
    RewriteCond %{HTTP_REFERER} !^http://www.mysite.co.uk$      [NC]
    RewriteRule .*\.(jpg|jpeg|gif|png|bmp|wmv)$ - [F,NC]
    ||||If you are getting paid to do a job, don't ask for help on it!||||


  •  

    Posting Permissions

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