Password protect site using htaccess

There is a situation where you want to be protect your site using htaccess that no body can access your site except you .

Step you need to be follow :

Create the Password File

  1. Open a new text file called
    .htpasswd
    Note the period at the beginning of the filename.
  2. Use a password encryption program to create your passwords. Paste the lines into your .htpasswd file and save the file. You will have one line for every username that requires access.
  3. Upload the .htpasswd file to a directory on your Web server that is not live on the Web. In other words, you should not be able to go to http://YOUR_URL/.htpasswd - it should be in a home directory or other location that is secure.

Create the htaccess File

  1. Open a text file called .htaccess Note the period at the beginning of the filename.
  2. Add the following to the file:
     AuthUserFile /path/to/htpasswd/file/.htpasswd
     AuthGroupFile /dev/null
     AuthName "Name of Area"
     AuthType Basic
     require valid-user
     
  3. Change
    /path/to/htpasswd/file/.htpasswd
    to the full path to the .htpasswd file you uploaded in above.
  4. Change "Name of Area" to the name of the site you want to be protected. This is used primarily when you have multiple areas with different protection levels.
  5. Save the file and upload it to the directory you want protected.
  6. Test that the password works by accessing the URL. If your password doesn't work, go back to the encryption programs and encrypt it again. Remember that the username and password will be case-sensitive. If you are not prompted for a password, contact your system administrator to make sure that HTAccess is turned on for your site.

3 Comments

  1. Purchasetheme is one kind of platform for the developers and designers. Whoever feels important can buy and sell the readymade work related to web development assets and print comprising scripts, codes, themes, banners, logos, graphics, plugins as well as mobile or desktop app source codes. Ajax Search Opencart

    ReplyDelete
Previous Post Next Post