How to Password protecting your development site with .htaccess or .htpasswd?

It is very simple just follow below instruction:

Step 1 :

Create a .htaccess file and upload to your server to the root of your dev site with the following content:

AuthName “Authorisation Required”
AuthUserFile “/path/to/.htpasswd”
AuthType Basic
require valid-user
ErrorDocument 401 “Authorisation Required”

N.B. : If .htaccess file already exists then you can add the above code on the top.
Also note that omitting ‘ErrorDocument 401 “Authorisation Required”‘ line can lead to 404 error.

Step2 :

Create and upload the .htpasswd file to ‘AuthUserFile’ path with the following content:

tigeranwar:$apr1$8xNFfAZO$okeuxEVCJbaJoFGFdzQ1A/

N.B. : Where ‘tigeranwar’ is the username and ‘$apr1$yB1.9vIT$IVVBmq5vMauwsNR8CZdHQ.’ is the MD5 encrypted password of ‘shafin123’.

You can generate password from below link location:

Htpasswd Generator – Create htpasswd

If you face any problem just reply me.