Protecting a folder and files inside folder from direct access

Discussion in 'Site & Server Administration' started by dadaas, Sep 25, 2013.

  1. #1
    Hi, please i need some help with protecting files on server.

    I have VPS server.

    I want to upload videos to a folder and then use this videos in SMF as posts (i will insert them as flash, so videos are actually flash .swf files)

    I want to lock direct access to videos, nobody should be able to see videos or what is int hat folder. As well downloading them.

    Please send me some tutorials or give me tips and tricks how to do it.

    Thanks
     
    Solved! View solution.
    dadaas, Sep 25, 2013 IP
  2. #2
    You will want to search up using .htaccess to do this for you. You can lock down a directory to specific items or even password protect it. Your forum should still be able to view these files depending on how you have it set.

    A quick google search for ".htaccess tutorials" will show hundreds of useful links.

    However I can give you some basic tips.

    Disable Directory view from browser:
    DirectoryIndex disabled

    Disable Hot linking:
    RewriteEngine on RewriteCond %{HTTP_REFERER} !^$
    RewriteCond %{HTTP_REFERER} !^http://(www\.)?mydomain.com/.*$ [NC]
    RewriteRule \.(gif|jpg|js|SWF)$ - [F]
    Code (markup):
    Password Protection:
    Requires a .htpasswd file with username and passwords.
    Format is username:password where password needs to be encrypted

    in .htaccess:
    AuthUserFile /usr/local/you/safedir/.htpasswd
    AuthGroupFile /dev/null
    AuthName EnterPassword
    AuthType Basic
    require user <username> 
    Code (markup):
     
    Jonathan VanSchaack, Sep 25, 2013 IP