Saturday 30 March 2013

Denying access to a particular folder on your web server

Suppose you have a directory in your web server which contains sensitive files like files containing database connection passwords , app-secret id's for using 3rd party services etc . You want to block access to that particular folder . So how are you going to do it ? Well it's pretty simple . Just add a .htaccess file to that folder . Open it up , and add the following lines :-


Order deny,allow
deny from all

This will deny access to any files in that folder . Remember that all those files in the folder can be accessed only if you add a require , include directive in a file on the server-side . However ajax calls or any sort of client request won't work on the files of that directory .

4 comments: