Htaccess is a password protection scheme used by Apache Web servers.The web server will ask an authentication to enter if we set a password for it.Here the steps explains how to set an authentication for the web folder.
- Create a file called .htaccess in your web folder which you want to protect.
- Open the file .htaccess in your favorite editor.
- Paste the lines below.
- Change the path of .htpasswd in AuthUserFile where you are going to place the .htpasswd file.
- Change AuthName to from “Protected files” to any name you would like.
- Change require user to any user name you would like to give (This will be the authentication user name it will ask).
- issue command htpasswd -c <htpasswd path> <username> for password setting . For me it is htpasswd -c /var/www/.htpasswd bipin
- Edit httpd.conf file or the web configuration file of apache.It should be like this.
AuthUserFile /var/www/.htpasswd AuthGroupFile /dev/null AuthName "Protected files" AuthType Basic require user bipin
<Directory /var/www/> Options Indexes FollowSymLinks MultiViews AllowOverride AuthConfig #AllowOverride none Order allow,deny allow from all </Directory>
Uncomment AllowOverride AuthConfig if it got commented.
Now onwards it will ask an authentication to enter into it.
