Jul 10 2008

Securing Web folder with htaccess

Category: LinuxBipin Balakrishnan @ 3:12 pm

seo.JPG

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.

  1. Create a file called .htaccess in your web folder which you want to protect.
  2. Open the file .htaccess in your favorite editor.
  3. Paste the lines below.
  4. AuthUserFile /var/www/.htpasswd
    AuthGroupFile /dev/null
    AuthName "Protected files"
    AuthType Basic
    require user bipin
  5. Change the path of .htpasswd in AuthUserFile where you are going to place the .htpasswd file.
  6. Change AuthName to from “Protected files” to any name you would like.
  7. Change require user to any user name you would like to give (This will be the authentication user name it will ask).
  8. issue command htpasswd -c <htpasswd path> <username> for password setting . For me it is htpasswd -c /var/www/.htpasswd bipin
  9. Edit httpd.conf file or the web configuration file of apache.It should be like this.
<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.