Knowledge Base
MilesWeb / cPanel

Steps to Enable Password Protection for .htaccess?

Approx. read time : 3 min

The article reveals the steps to enable .htaccess password protection.

1. Firstly, create an .htpasswd file with your own username and password in any text editor and save it without the .txt extension. Encrypt the password for extra protection.

2. After visiting the link, just enter the username and password. This will generate the code for you that you just need to copy and paste. In this example, the username was ‘abc’ and password too was ‘abc’ and so the result was – abc:9476nIHW7Esgw. But it generates a new one each time.

3. Next, create an .htaccess file with the below code. You can use any text editor save it without the .txt extension. Don’t miss to check the .htpasswd file’s location or else it won’t work.

4. It is possible to change the ‘Login Details’ to anything you want to be displayed on the pop-up alert.

AuthUserFile /home/user/domain/secretfolder/.htpasswd
AuthType Basic
AuthName “Login Details”
Require valid-user

5. Both these files need to be uploaded in the same folder which you want to be secure. Now, if any other user than you tries to access that directory or any files in it, they will be asked for login details. So, your web directory is now secured with the password.

NOTE – You won’t be able to see these files on your server as they are hidden files. You can view the Filezilla FTP client and check the “force showing hidden files” option to view these files. You can also create these files easily in Notepad but save them without .txt extension (Save a type – select “All Files”, then you can save without any extension). In case the Login window keeps popping up, it indicates that your login details are wrong.
That’s it! You have now learned to enable password protection for .htaccess.
Pallavi is a Digital Marketing Executive at MilesWeb and has an experience of over 4 years in content development. She is interested in writing engaging content on business, technology, web hosting and other topics related to information technology.

Trusted By Thousands of Clients & Big Businesses

We highly appreciate the kind and stellar feedback we receive from our customers. Delivering the best is our goal! MilesWeb is rated Excellent out of 5 based on reviews. Read more reviews.

Excellent
Based on reviews
2 hours ago
Perfect and Valuable Server + ...
I am using MilesWeb Servers, The main thing which I getting are continuous support over everything w...
Gunjan Makwana
4 hours ago
Milesweb is superb Hosting pro...
Milesweb is superb Hosting provider ever, their Support team is amazing!!!...
Abhishek Singh
15 hours ago
Great support in great timing...
We need urgent assistance on changes in a primary domain on our client's Cpanel accounts and reached...
Riyaju Deen
21 hours ago
Best Website Hosting platform ...
I was new on MilesWeb. And needed help on multiple areas from setting up to getting started with cre...
Harshada
1 days ago
Very quick and helpful assista...
Very quick and helpful assistance. Support person listened properly and provided a nice solution....
Narendra
1 days ago
the team is very supportive th...
the team is very supportive though at times effort needs to be made to make understand the problem s...
Suree Sharma
1 days ago
I am using miles web for 3plus...
I am using miles web for 3plus years, very quick and perfect support by the team, they helped me man...
Sri Raghav
2 days ago
The service is good...
The service is good. They are answering with patience and doing the needful as soon as possible....
MR
2 days ago
Perfect and Valuable Server + ...
I am using MilesWeb Servers, The main thing which I getting are continuous support over everything w...
Gunjan Makwana
3 days ago
Very quick and helpful assista...
Very quick and helpful assistance. Support person listened properly and provided a nice solution....
Narendra
4 days ago
positively helped me with find...
positively helped me with finding insecure content on my website causing SSL to not work properly on...
Thaviraj Junglee
4 days ago
Exceptional support, Truly Pra...
I had opted for the basic wordpress hosting plan as I intended to experiment with various plug-ins. ...
Aseem Chandna