July 6, 2021 . 2 MIN READ
You can password protect your website, or any of its directories, through basic authentication using a .htaccess file. PHP must be set as the default technology for a site in order to utilize a .htaccess file. If used on a site where ASP is also an enabled technology, please be aware that this will not protect ASP pages.
Create the .htaccess file
This file sets up the requirement for basic authentication and also points to the file containing a list of authorized users.
# The name of the areaAuthName “Name of Password Protected Area” # Type of authentication. Always basicAuthType Basic # Path to .htpasswd file for the site.# It’s preferable to not have this in any# of the site’s content directories.AuthUserFile /mnt/Target01/[DDI_ID]/[CLIENT_ID]/[WEBSITE_NAME]/.htpasswd # The requirements to view the site. This# requires that the browser provide# credentials matching on of the users in# the .htpasswd file specified above.Require valid-user
Create the .htpasswd file
This file will contain a list of usernames and password sets. Each line should contain one set and the username and password should be separated by a colon
Following these steps will setup basic authentication password protection to the directory indicated. If you are unable to view the .htaccess and .htpasswd files after you renamed them, you will need to configure your FTP client to view hidden files.