Hiding and protecting a directory with htaccess

David Carr

Htaccess Tutorials

When building web applications is makes sense to hide sensitive files such as say a config file into a folder that will only be accessible via a script and not directly.

One way is to name the directory with a . then the name so if you have a folder called includes rename it to .includes the folder is still accessible but FTP programs and the like hide folder prefixes with a . then to make it locked down place a .htaccess file inside it and place the following:

order allow,deny
deny from all

This disables all access by denying anyone from access the folder. You can still use the files inside the directory by including them into your scripts.

Laravel Modules Your Logo Your Logo Your Logo

Become a sponsor

Help support the blog so that I can continue creating new content!

Sponsor

My Latest Book

Modular Laravel Book - Laravel: The Modular way

Learn how to build modular applications with Laravel Find out more

Subscribe to my newsletter

Subscribe and get my books and product announcements.

Fathom Analytics $10 discount on your first invoice using this link

© 2006 - 2024 DC Blog. All code MIT license. All rights reserved.