How to create a password to access the site in htaccess

1 min


Create a password in the .htaccess file for private access to the site.

File contents .htaccess:

AuthType Basic
AuthName “Protected Zone”
AuthUserFile /home/…/.htpasswd
Require valid-user

# Deny browser access to the .htpasswd file
deny from all

For security reasons, the file htpasswd place on the directory above the site (usually this public_html, therefore, put on a higher level).

Inside the file .htpasswd there should be passwords in the following form:

UserName1: $ apr1 $ dfkmDs $ kgsg83mdgskgjDms3mKD

where after the colon is the password encrypted in MD5… Other formats are also possible, such as crypt or SHA.


0 Comments

Leave a Reply