How to protect development server by setting up http password in Magento

Step 1 

Create .htpasswd file in your magento root directory

Step 2

Go to following URL and generate the encrypted password for your .htpasswd file:
http://www.htaccesstools.com/htpasswd-generator/
Note: after generating your username and password should be looks like as follows:
yourusername:$apr1$yJG52MaR$V3Wk/X00p7HzXAz7fGg.N.

Step 3

Copy this line and paste in your created .htpasswd file.

Step 4

Open your .htaccess file in magento root and paste following piece of code bottom of the file:

AuthType Basic
AuthName "Restricted Area"
AuthUserFile /var/www/PATH_TO_YOUR_MAGENTO_INSTALLATION_PATH/.htpasswd #this should be full path to your previously created .htpasswd file.
require valid-user

That’s it. Now when you open your pre-production server URL, you will prompt to entering your http password. If you forget your encrypted password then again regenerate new password and paste it your .htpasswd file in your Magento root.

Please note that sometimes you may need to clear your Magento cache, your web browser cache to view that password popup dialog box. Also you may need to restart your web server. To restart your apache in Linux box you can use following command:

sudo /etc/init.d/apache2 restart

or:

sudo service apache2 restart

If you use nginx, the command is:

sudo service nginx restart

(This list can help in case of problems).

Enter your root password when asked.

Leave a Reply

Your email address will not be published. Required fields are marked *