Email-Icon Created with Sketch. Group 3 Created with Sketch. Domains-SVG-Box Created with Sketch. Domains-SVG-Box Created with Sketch. Domains-SVG-Box Created with Sketch. Hosting-SVG-Box Created with Sketch. Hosting-SVG-Box Created with Sketch. Icon-Internet Created with Sketch. Hosting-SVG-Box Created with Sketch. Icon-Internet Created with Sketch. Icon-Internet Created with Sketch. Trust Pilot Stars Created with Sketch. 1-5-million Created with Sketch. Control-panel-Icon Created with Sketch. WSB-Brush Created with Sketch. WSB-Brush Created with Sketch. WSB-Brush Created with Sketch. Email-Icon Created with Sketch. Email-Icon Created with Sketch. Email-Icon Created with Sketch. Email-Icon Created with Sketch. Icon-ECommerce-Seperator Created with Sketch. Icon-ECommerce-Seperator Created with Sketch. Icon-ECommerce-Seperator Created with Sketch. icon-slider-next Created with Sketch. icon-slider-prev Created with Sketch. Webmail-icon Created with Sketch. heart Created with Sketch. Open-24-7 Created with Sketch. open24 Created with Sketch. 24 7 trusted Created with Sketch. Fill 1 Created with Sketch.

How can I protect my website with a password?

With .htaccess it is possible to protect your website with a password, so only authorized users can access it.

Step 1 - Generate the code
Step 2 - Create the .htaccess file
Step 3 - Create the .htpasswd file
Step 4 - Verify the result

Step 1 - Generate the code

First you need to generate the code. To make it easier for you we have created a tool for this.

  1. Go to the One.com .htaccess Tool and fill out the fields.
  2. Click on Generate files when you are done.
Tip: If you only want to protect part of your website with a password, enter the name of the directory (folder) you want to protect in the Directory name field, for example wp-admin.
htaccess tool
  1. Keep this page open in a separate window, you will need the information later.
Tip: You can change the language of the .htaccess tool by clicking on the little flag in the top right corner.
generate the code

Step 2 - Create the .htaccess file

You now need to create two files and insert the code you just generated. Start with the .htaccess file.

  1. Open a new browser window and log in to your One.com control panel and open File Manager.
  2. Click the arrow right of the upload button and select New other file.
Note: If you only want to protect a specific directory (folder) and not your whole site, you need to create the .htaccess and .htpasswd files in the folder that you want to protect.
create htaccess file in file manager
  1. Name the file .htaccess and press Enter on your keyboard.
  2. Select the .htaccess file and click Edit.
Note: Don't forget the . (dot) at the beginning of the file name, so it looks like this: .htaccess.
edit the htaccess file
  1. Enter the generated code for the .htaccess file, this is the second bit starting with AuthName.
  2. Click Save.

In this example the code looks like this:

AuthName "This site is protected with a password" AuthType Basic AuthUserFile /customers/c/8/e/one-example.com/httpd.www/.htpasswd AuthGroupFile /dev/null require valid-user
enter code in htaccess file

Step 3 - Create the .htpasswd file

Stay in File Manager to create the .htpasswd file. This file will contain the username(s) and the encrypted password.

  1. Click the arrow right of the upload button and select New other file.
  2. Name the file .htpasswd and press Enter on your keyboard.
  3. Select the .htpasswd file and click Edit.
  4. Enter the generated code for the .htpasswd file.
  5. Click Save.

In this example the code looks like this:

John:U2C5Dlti5s6EM
enter code in htpasswd file

Step 4 - Verify the result

Go to your website and verify that it works. A popup should appear asking you to enter your user name and password.

Enter the user name and password you specified earlier, when generating the code and click Log in to access your website.


login window htaccess

Congratulations, you are now done!


Related articles