>How to Create HTPASSWD for Magento Site

How to Create HTPASSWD for Magento Site

When you start your store website with Magento, one of the most important things to do is create .htpasswd for Magento site. It’s, of course, clear that this htpasswd will enhance site security by protecting content and information of the site from leaking or hacking.

So how we can create htpasswd for a Magento site? In this blog post, we will provide you the way that you can generate htpasswd on your own.

Step 1:

Use FTP or Cpanel to go to the folder containing Magento code

Step 2:

Open .htaccess file and insert the following code into the file (we can also insert this code into the top of the file)

AuthUserFile /patch/to /.htpasswd

AuthType Basic

require valid-user

AuthUserFile must be the correct server path

We can get the server path by using ssh, go to the code folder and type: pwd

Or we can put this PHP command into some test file & run it from the browser:

<?php  echo $_SERVER[‘DOCUMENT_ROOT’] ?>

So what we have, for instance:

AuthUserFile  /home/user/domain.com/.htpasswd

Step 3:

Create a file .htpasswd at the same level with .htaccess file

In this step, it is not mandatory that these files are at the same level, but the path must be correct.

Step 4:

Go to http://www.htaccesstools.com/htpasswd-generator/, type your desired username and password and copy the returned result.

Step 5:

Go to .htpasswd, paste the above result and save these files. Finally, you go to your site to check again

With 5 simple steps, you create htpasswd for your Magento site easily to make it safer and more confidential.

Do you find our today tutorial useful? Let’s Like, Share and Subscribe for more new knowledge.  We are a team including talented and professional developer about Web Development and Magento Extensions, and we are always willing to support you. Feel free to contact us every time!