You probably have a private website that you don’t want to share with the world. You might also probably want people to pay a membership fee in order to be able to access your web page. Whatever your reasons may be knowing how to password protect a web page can be very useful and the good news is that its not very difficult. You can password protect files, folders, and other documents and even entire directories. You can then also set permissions allowing only a selected few people to access that portion of your web page.
There are two ways in which you can go about password protecting your web page the first is through htaccess and the other is via cgi short for common gateway interface. For the sake of this discussion we are just going to look into how to password protect your web page using htaccess since it’s the easiest and the most commonly used method of protecting a web page.
Now.htaccess is actually the default name for the Apache directory where all the configuration files are kept. The file here i.e. the.htaccess file contains instructions to allow the server to behave in a certain manner.
You can create a file using a htpasswd generator containing your username and password separated by a colon. Alternatively if you have SSH access to the server. All you need to do is to SSH to connect to your sever and bring up the terminal window, type cd in the folder where you want to create the password and type: htpasswd -c.htpasswd uname.
You can also choose to password protect a folder using the following lines of code: AuthUserFile /fullpath/.htpasswd AuthType Basic AuthName “Hide Folder” Require valid-user.
As you can see password protecting a webpage or folder is not difficult using htaccess.