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.
deny from all
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.
Order Deny,Allow Deny from all Allow from xxx.xxx.x.x
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.
You must log in to post a comment.