Skip to content Skip to sidebar Skip to footer

Protect directory folders with .htaccess Auth

Htaccess

Folder protection is necessary to restrict users who can enter an area and of course many folders can be used to provide a login system for users. But there is a very simple and very practical way to get in Creation of the login systemas it only needs 2 files to be edited.

In this article I explain how to protect folders with files .htaccess. On the other hand, .htaccess has a different algorithm that can save the logged in user than .htpasswd, with proven encrypted passwords are not easy to recognize.

The .htaccess file is basically the main brain of a server that it can be used with for redirecting, modifying, etc. Any hosting can be described Error editing .htaccess There may be a fatal error showing the HTTP Code 500 response. Same as php.ini but the file is still being disabled by the hosting server because it can outsmart the server system

Perform authentication in the form of a login, which contains a user name and a password, can also be used by other programming languages ​​such as PHP, ASP, Java and so on, so that not only can .htaccess authenticate users, but is also conveniently easy to create with .htaccess. Here’s how to do it.

AuthUserFile /home/user/public_html/.htpasswdAuthGroupFile /dev/nullAuthName "Private Directory"AuthType Basicrequire valid-user
  1. 1. First copy the code above and pay attention to the /home/user/public_html/.htpassw Please change the location of the CWD server.

  2. After that, paste it into the .htaccess file on the top line so that no fatal error occurs.

  3. Then create a file called .htpasswd in the ROOT server, usually in the folder public_html or www or html.

  4. Next, please go to the htpasswd creation page below http://htaccesstools.com/htpasswd-generator/ and enter the username and password. Then a text area and an encrypted username and password appear, please copy and paste into the file .htpasswd.

  5. Now please test whether it can work properly. If a serious error occurs, please check again on the CWD server, which is listed in the .htaccess Authname file, whether it is correct or not.

This method can also be used for Protect admin login folder like wp-admin to make it safer from the hands of the prison. Should you ever forget the password, it can be generated again as above on the htaccess-Tools-Site.

Now any folder that contains important files or pages can be protected in a very convenient way. My advice Do not use a txt file for htpasswd storage User password as it can be read by search engines. : Mr. Green:

Hopefully useful and good luck