We can use simple password protection to keep users from seeing your latest development on the web until you are ready. By using the .htaccess file in the folder we want to password protect and an .htpasswd file outside of the /public_html/ folder to specify the users we will be able to lock out the public until our theme / project / site / etc. is complete.
This is a very simple and easy solution when you want to give access to your entire development environment (new theme, new website, etc.) to a client or colleague.
Create An Access List
Use SSH to remotely access your website and navigate to your home directory. The .htpasswd file can be anywhere on your web directory but should not be in the public_html folder.
cd ~/ pwd

Use the htpasswd command to create the .htpasswd file and add a user ‘guest’.
htpasswd -c .htpasswd guest

Enter the password twice. You can see the contents of the new file by using this command
cat .htpasswd

Authorized users will be added to this file. If you want more than one user use the htpasswd command without the “-c”.
htpasswd .htpasswd guest2

Password Protect a Folder (directory).
Open your code editor and go to the folder you want to password protect (or create a new folder). I have created a folder named ‘solitude’.
Create a file called .htaccess and enter your information in this format. Note that this file is inside the folder you want to password protect. If this file is in your public_html folder then your entire website will be password protected.
AuthName "Members Area" AuthType Basic AuthUserFile /path/to/your/.htpasswd Require valid-user
If you don’t have any pages in the directory yet try adding a single index.html page with “Hello World” or some other such text.
To test the security out open your browser to yourdomain.com/solitude and you should be prompted for a username and password.

Upon successfully typing in your credentials you should be in and be able to see your content. In this case, the index.html will display.



