Protect site with password using htaccess. The htpasswd file is just a text file that includes usernames and password hashes. You can generate those by using online tools for generating htaccess passwords. First bit of code is simplest htaccess password protection code that needs to be copied to your .htaccess file. The second one enables you to password protect defined directories using regular expressions.
Source code viewer
# Global password protection AuthUserFile /full/directory/to/htdocs/.htpasswd AuthName "Password Protected" AuthType Basic Order Deny,Allow Deny from all Satisfy any Require valid-userProgramming Language: Apache configuration
Source code viewer
# Password only on ^/bank/notification SetEnvIfNoCase Request_URI ^/bank/notification require_auth=true AuthUserFile /full/directory/to/htdocs/.htpasswd AuthName "Password Protected" AuthType Basic Order Deny,Allow Deny from all Satisfy any Require valid-user Allow from env=!require_authProgramming Language: Apache configuration