Results 1 to 2 of 2

Thread: Prevent hotlinking -in a folder- using htaccess

  1. #1
    Join Date
    Apr 2006
    Posts
    32
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Prevent hotlinking -in a folder- using htaccess

    I need to prevent hotlinking to all zips in a folder using htaccess, and redirect the result to a page.

    I also need all images in that same folder to show up a "No hotlinking" image.

  2. #2
    Join Date
    Aug 2004
    Posts
    10,143
    Thanks
    3
    Thanked 1,008 Times in 993 Posts
    Blog Entries
    16

    Default

    You can't really prevent hotlinking of zip files, as they are never really hotlinked, unlike images. Zip files are always just linked to by other sites. If you're looking to stop that, you need to find a way to dynamically serve up the zip files using CGI or PHP. There are scripts out there that do that, but it's not within the capability of .htaccess.

    To prevent hot linking on images inside a folder on your site, insert the below code into a blank .htaccess file, and upload it to that folder (in ASCII):

    Code:
    ## DISABLE HOTLINKING
    RewriteEngine on
    # Options +FollowSymlinks
    RewriteCond %{HTTP_REFERER} !^$
    RewriteCond %{HTTP_REFERER} !^http://(www\.)?yourdomain.com/.*$ [NC]
    RewriteCond %{HTTP_REFERER} !^http://(www\.)?yourotherdomain.com/.*$ [NC]
    RewriteRule \.(gif|jpg|jpeg|png|zip)$ - [F]

Bookmarks

Posting Permissions

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