HTACCESS Deny From All

by Mike Lugar
image title

Denying access to a directory on your web server is an important feature to use especially if you have folders that you would like hidden from the rest of a public site. For example, you may keep the download file of a digital product on your eCommerce website, or use a directory for files you do not want to be public. One of the easiest and most commonly used ways to do this is through a .htaccess file that you can place within the directory you wish to restrict.

Simply create a blank file called ‘.htaccess’ using a text editor and place the below on the first line of the file. Then, copy the .htaccess file you just created to any directory you wish to restrict on your web server.

Denying Access From All But You

An alternative to the above is to restrict access to the directory from everyone except you (your IP address). In order to do this you will need to create a .htaccess file and use the below syntax replacing ‘xxx.xxx.x.x’ with your IP address. Then, place the .htaccess file in the directory you wish to restrict.

As you can see, there are several ways you can tailor a htaccess file to restrict your website directories. It is also a very simple and easy solution despite more complicated server level options to restrict access.

Mike Lugar
Mike is the managing member at MSLtek and is an avid web consultant and web developer. He enjoys solving complex problems and helping businesses connect with technology.
Posted on August 8, 2016

Would you like us to send you a quote?

Get A Quote