

htaccess Authenticationīy default Apache doesn’t allow to use of. -m : is used to save password in md5 format.Ĭonfigure Apache to allow.If you use it second time, it will remove existing file and recreate new one. -c : is used only for first time when you create.You can add user and password either in plain text or md5 encrypted.Īdding password in plain text format: # htpasswd -c /home/myuser/public_html/.htpasswd myuserĪdding password with md5 crypt format # htpasswd -cm /home/myuser/public_html/.htpasswd myuser require valid-user: indicates that only successful authenticated requests may load of the page.AuthUserFile: is file which stored user credentials.AuthName: is content which displayed on web page when prompts for user name and password.Basic means there is no encryption and the password hash is sent as clear text. AuthType: defines the type of authentication.AuthType BasicĪuthUserFile /home/myuser/public_html/.htpasswd

htaccess file in your website document root to protect entire site or in specific directory and add following content. One of the most common uses is to require user authentication in order to serve certain web pages. This is the default Apache directory level configuration file.htaccess can be used to secure a particular directories in web server.
