Mytour will guide you today on how to secure your website with a username and password. The process of password-protecting a website can vary depending on where the site is hosted. Whether you write code directly on the server or upload files from your computer, you can set a password for your website using an .htaccess file. If you're using website builders like Squarespace or Wix, you can set a password for specific areas of the site through the admin control panel. For those using advanced hosting solutions that allow user accounts, contact your hosting provider for guidance.
Steps
Using the .htaccess File

Create a text file named .htpasswd. This file stores the list of usernames and passwords that users will need to access the site. You can create this file on your computer if you plan to upload it to the server via FTP (file transfer protocol). If you're logging into the web host via SSH or other methods, use the server’s text editor to create the file. Note: Since this file contains sensitive password information, make sure not to store it in any publicly accessible directory on your website.
- For example, if you want users accessing https://www.Mytour.com/test to be prompted for a password, upload the website files to this location on the server: /www/sites/www.Mytour.com. However, do not place the .htpasswd file in that directory. Instead, save it in a different directory (e.g., /usr/home/yourusername).
- If you do not have access to the main directory outside of the web folder, contact your web hosting support team and inform them that you need to store the .htpasswd file elsewhere. They will assist you with the next steps.

Generate an encrypted password at http://www.htaccesstools.com/htpasswd-generator. Storing passwords in plain text is not very secure, so you need to use an online encryption tool to generate the password. Here's how you do it:
- Enter the username in the 'Username' field. This is the name that one or more users will use to log in and access the website.
- Enter the password for that username.
- Click Create .htpasswd file to generate the file.
- The username and encrypted password will be separated by a colon. For example, if you entered Mytour as the username and badpassword as the password, you would get: Mytour:$apr1$k7iNRs8E$jL98Y2BEGl2qaF61PuiJ/1.
- Select the entire line, right-click the highlighted text, and choose Copy.
- The encrypted password is not the password that the user will enter to access the site. They will enter plain text, while the encrypted version is only for the server.

Paste the copied text into the file by right-clicking the first line of the empty file and selecting Paste.
- The .htpasswd file can contain multiple username and password pairs. Simply enter each username and password combination on a separate line.

Save and close the file. If you created the file on your computer, upload it to the server immediately. Remember, DO NOT save the file in a directory that can be accessed publicly on the web.

Create a new text file named .htaccess. Similar to the previous file, you can create it on your computer if you plan to upload it directly to the web server or use FTP. Unlike the .htpasswd file, the .htaccess must be stored in the directory you want to protect with a password.
- If you want to protect the website https://www.Mytour.com/test with a password, save the .htaccess file in the subdirectory /test/ (for example, /www/sites/www.Mytour.com/test/).

Paste the code into the file. The example below assumes that your .htpasswd file is stored in the /usr/home/yourusername directory. Replace this with your actual path and save the file as .htpasswd.
AuthType Basic AuthName "Protected Site" AuthUserFile /usr/home/yourusername/.htpasswd require valid-user

Save and exit the file. If you created the file directly on the server, you're all set. However, if you edited it on your computer, be sure to upload the file to the directory you want to protect with a password.

Test using a web browser. When accessing the protected page via your web browser, the website will prompt you to log in. Enter the username and password in plain text (not the encrypted version) to proceed. Test both valid and invalid password scenarios.
Utilize online website building tools

Log into the website's administrator dashboard. If the website is managed through an online website builder like Squarespace or Wix, you can use their page editor to set a password for restricted areas.
- Some services may require an upgrade to a higher plan to enable password protection. Others might not have this feature at all.
- The specific steps will vary depending on the hosting service.

Navigate to the page or section you wish to protect. In most cases, this will be under the Pages section.
- Unless you want to protect the entire website, avoid selecting the homepage/index. If you're only looking to set a password for a specific page, make sure to navigate directly to that page in the editor.
- If you want to require a password to access a particular blog post, like on Wordpress.com, look for the password settings under the New Post section.

Navigate to the Settings section of the chosen page. For example, on Squarespace, click or tap the menu in the top right corner to access the settings. If you're using Wix, click on the three-dot menu and select Settings.

Activate password protection for the page. Some websites require you to click a toggle or checkbox to adjust the page's visibility, while other services only ask you to input a password.
- If you're on Wix, click on the Permissions tab and select Password Holders, then enter your password.
- On Squarespace, simply enter your password in the "Password" field.

Save your changes and verify the password.

Test the password protection. Once set up, use a web browser to check by visiting the protected URL. Try both cases: entering the correct password and an incorrect one.

Contact your web hosting service for guidance. If you're having trouble or are unsure where to find the password settings, reach out to your web hosting service's support page for assistance. Most of these services are run by experienced administrators who are eager to help you secure your website.
Advice
- Test the password protection of the website. Try to bypass it or ask friends with programming/hacking experience to attempt access.
- It's crucial to have a deep understanding of how password protection works so you can identify vulnerabilities that need to be addressed.
Warning
- If you lack experience, do not trust sensitive data to password protection alone. Many common password protection techniques available online today are not very secure when facing professional hackers.
