How to set up Password Protection with htaccess / htpasswd on your WordPress?
Find below download link (.zip file) to our “Work in Progress” project and feel free to use it
or see our GitHub repository
When you work on some WordPress project and want to grant access to your web only to those who are authorized to see it or you simple want to turn on maitenance mode. You can do this by creating a .htaccess and .htpasswd files.
We have prepared a project that will allow you to do it in a very simple tool that will help you to not break your website while testing and experimenting.
How it works?
When you will try to enter website, you will see Authorization Required window.
If the attempt to enter the password fails, the following Landing Page will show up. Fell free to modify this file (wip.php)
How to generate new password in .htpasswd?
When you download zip file with our “Work in Progress” project, you will see, among others the .htpasswd file in which the two default access points, i.e.
# 1 access
user: tmc password: tmcstart
# 2 access
user: tmc password: pass!@#
Please feel free to change it to set your password and user name.
When you will open file you will see both accesses encoded in 2 separate lines (Remember only one entry per line!):
When you don’t know how to create line with access go to website http://www.htaccesstools.com/htpasswd-generator/
and type new username and password.
After clicking “Create .htpasswd file” you will see that .htpasswd entry were created
Copy the text into your .htpasswd file.