With htaccess it becomes very easy to protect a folder or directory and this method is simply referred to as “htaccess authentication”. In order to protect your folder password with htaccess , you need to upload two files; .htaccess and .htpassword within the directory in which you want to password-protect, if you have not these files on your server, you can create new ones using Notepad just make a new file and save it without name just .htaccess extension, and set file type as All Files as the following image.
In order to use htaccess to protect a folder password , you need to use the following commands;
AuthType Basic AuthName “Password Protected Area” AuthUserFile /path/to/.htpassword Require valid-user
All these components are already in the htaccess file and all you need to do is to change the path/to/.htpassword/ and choose the password you want to use. The next step is to upload the .htpassword file that contains both the username and password and then you can enter the password protected file. You may need to use a password generator to create another password for the file but you must keep in mind that each line of the .htpassword command will have a different combination of username and password.
You can create the .htaccess file using a good text editor like TextPad, UltraEdit and Microsoft WordPad. You cannot use Microsoft NotePad. An .htaccess file can contain a single or multiple lines depending upon the functions you want to include in it. You will need to use an FTP (File Transfer Protocol) program to upload the file. Also you must to upload the file in “ASCII” mode. Some FTP programs use “BINARY” as the default to upload files. If that’s the case you must change it to “ASCII”. Upload the file to the directory you want it to reside in. when you look at the files in your website’s directory you might not see it as your web server’s software is probably hiding it.