2015年1月7日 星期三

[Apache] Overriding .htacess Files in Server

Sometimes, we may want to control the download behavior  through http server, in this case, we often need to override the htaccess config file to achieve.


Scenario 1: No authentication is needed
1) Make .htacess file with the below content
  
   
     Allow from all
     Satisfy any
   

2) After that, put the file to the directory, the following is the result (hierarchy level)

downFolder
     yourFileName
    .htacess 

So everytime the user download the file, they will not be asked for password


Scenario 2: Authentication with Username and Password

1) Make .htacess file with the below content
  
    AuthType Basic
    AuthName "yourProtectedMsg"
    AuthUserFile pathOfYourHtapasswdFile
    Require user loginUsrName
  

2) After that, make a .htpasswd file from the following URL
http://www.htaccesstools.com/htpasswd-generator/

3) Put .htacess, .htpasswd file to the same directory as your file
downFolder
     yourFileName
    .htacess 
    .htpasswd

So everytime the user download the file, they will be asked for password

沒有留言:

張貼留言