In this guide, we explain how to protect your Website Builder website - or a specific file or directory - with a password, so that only authorised users can access it. This method is primarily intended for password protecting websites created in Website Builder. If you want to password protect a WordPress site, we recommend using a plugin instead.
- Step 1 - Open File Manager in the one.com Control Panel
- Step 2 - Generate the .htaccess and .htpasswd files
- Step 3 - Paste the configuration in the existing .htaccess file (optional)
- Step 4 - Create a username and password
- Step 5 - Adjust the .htaccess configuration to protect a specific file (optional)
- Step 6 - Done!
- Step 7 - Solution for republishing
Note: It is not recommended to password protect a Webshop, as doing so may cause issues with the images in the shop.
Step 1 - Open File Manager in the one.com Control Panel
- Log in to the one.com Control Panel.
- Click File Manager under Files & Security.
Step 2 - Generate the .htaccess and .htpasswd files
You need to generate the files at the location that you want to protect. So, if you want to protect your entire site, stay in the main directory. If you're going to protect a single file or folder, you need to go to that directory.
- Go to the directory (folder) you want to protect with a password.
- Click the downwards arrow next to the + Upload button and select Secure directory.
Step 3 - Paste the configuration in the existing .htaccess file (optional)
Note: You only need to follow this step if you already have an existing .htaccess file.
- Select and copy the lines provided in the middle of your screen.
- Select the .htaccess file and click Edit.
- Paste the configuration at the top, above the existing rule(s).
- Click Save at the top of your screen.
Step 4 - Create a username and password
You can create as many logins as you need and remove them again. The username can only contain letters and numbers.
- Select the file called .htpasswd.
- Click the large file icon to the right on your screen.
- Enter a username and password. Remember to save the password somewhere else.
- Click Save.
Tip: If you don't remember the password, you can simply remove the existing user by clicking the "x" next to the user, and then create it again.
Step 5 - Adjust the .htaccess configuration to protect a specific file (optional)
Follow these steps to adjust the .htaccess configuration to protect only a single file and not the entire directory.
- Select the .htaccess file and click Edit.
- Adjust the code by adding the following lines at the top and the bottom, replacing "file-name-here" with the file you want to protect:
<Files "file-name-here">
<--- existing code --->
</Files>
- Click Save at the top of your screen.
Step 6 - Done!
When you open your website in a browser, you will now see a login screen asking for the username and password.
Step 7 - Solution for republishing
If you want to make changes to your website and need to republish it, your .htaccess file will be overwritten. This means you'll need to repeat the process above each time, which isn't ideal.
But don’t worry - we have a solution!
1. Copy the current code from .htaccess and save it somewhere, then delete it from the .htaccess file
2. Go to the Website settings in your Website Builder Dashboard, then Security. Disable HTTPS and Beautify my URLs
3. Set up the password protection from step 2 according to the guide above.
4. Paste the previously saved code into the .htaccess file below the password protection section.
Related articles: