Creating .htpasswd for 401 authorization. If you want to do basic authorization at the apache-server level, you need to generate a .htpasswd file. Htaccess files apply to the current directory and to all subdirectories below.
This password is generated using htpasswd and is suitable for Linux and Windows.
Copy this line into your .htpasswd file (remember, only one entry can be in a row):
To restrict access to the selected directory, copy these lines into your .htaccess file:
To restrict access to the private.zip file only, copy these lines to your .htaccess file:
Please note that .htaccess and .htpasswd files must be saved in unix format. For example, in Far Manager, this can be achieved if you press Shift + F2 in the file editing mode and select "in UNIX (LF) format" in the menu that appears.
Directives and a description of the .htaccess file used to restrict access
- AuthType – The type of authentication used. For basic authentication, this directive should have the value: Basic.
- AuthName – The name of the authentication scope. Text that helps the visitor understand where he is trying to access. For example, it might say: "Private zone. Only for administrator!".
- AuthUserFile – full path to the password file (.htpasswd). Relative paths will not work.
- AuthGroupFile – path to the groups file, if one exists.
- Require – One or more requirements that must be met to gain access to a restricted area:
- require valid-user – allowed access to all authenticated users
- require user admin alex mango – only visitors with the names admin, alex, mango are allowed access. Naturally, they must be authenticated
- require group admins – allowed access to all users from the admins group
You must be logged to leave a comment.
Popular SEO Tools / All Tools