When building WordPress sites, we often password protect them before we launch them so the half baked content is not accessible to the world.
The quickest way to do this is use simple htaccess password protection, assumes you’re using unix or linux based web server and apache, but that’s almost a given 🙂
First up you need to create a htpasswd file, this is an encrypted file that has a username and password stored in it that is for a valid user to access the site.
If you use a Mac or Linux computer you will be able to do this directly on your computer. Open a terminal and use the htpasswd command to create a file
htpasswd -c afilename peter
Usually the file name (afilename above) is .htaccess but you can actually call it anything you like, on the end you simply enter the username that you’d like to make a password for.
This file then needs to be uploaded to your web server, I usually place it in the web site root, but again you can place it where you like but you need to know the path to it on the server, see below.
Be aware that WordPress will automatically make a file called .htaccess and place it in the root of your web site, it uses this to setup your permalinks.
So, find this file (you can make it if WordPress has not already) and place the following code into it.
AuthType Basic AuthName "Password Required" AuthUserFile /path/to/your/.htpasswd <Limit GET POST> require valid-user </Limit>
That should be all you need to do, visit the web site and you should be promoted for a username and password, similar to the screen shot below.