Frequently asked questions


How can I password protect a directory?
In order to do this, you will need Unix shell access (webhotel Medium or larger). Follow these steps: (Do not include the quote signs around commands when running them)

  1. Login to your website with SSH, with a program like PuTTY or SecureCRT (Windows), Terminal (MacOS).
  2. Create an empty file named .htpasswd, do this by executing the command "touch .htpasswd"
  3. You now need to find the path of your website, you can do this by executing the command "echo $HOME", which returns the path to your home folder. You can also find this via the webhotel's control panel, by viewing the webhotel's primary address or disk usage.

    Substitute this for /home/1/y/youruser/ in the following examples.

  4. Next you run the command htpasswd -csb /home/1/y/youruser/.htpasswd username password

    Note that this command overwrites the file .htpasswd if it already exists!

    To add another username and password, enter this command:

    htpasswd -sb /home/1/y/youruser/.htpasswd username password 
  5. Create a file named .htaccess on your local computer and insert this information, replace //home/1/y/youruser/.htpasswd with the path to your .htpasswd.

    <Limit GET POST>
      Order deny,allow
      AuthType Basic
      AuthUserFile /home/1/y/youruser/.htpasswd
      AuthName "Password protected area"
      Require valid-user
  6. Upload .htaccess to your webspace, and place it in the folder that needs password protection. You can copy the same .htaccess to multiple folders.

For security reasons, it is important that the name of the password file is ".htpasswd", and that it is located, if possible, in a different directory than the website. The content of files named .htaccess and .htpasswd are not displayed via WWW unless you override this in .htaccess.

For more info about password protection under Apache, see here:

See also:

© 2024 Domeneshop AS · About us · Terms · Privacy policy