How to Password Protect a Web Page

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