Nov 17


what is .htaccess ?

In several web servers (most commonly Apache), .htaccess (hypertext access) is the default name of directory-level configuration files. A .htaccess file is placed in a particular directory, and the directives in the .htaccess file apply to that directory, and all subdirectories thereof. It provides the ability to customize configuration for requests to the particular directory. The file name starts with a dot because dot-files are by convention hidden files on Unix-like operating systems. A subset of Apache’s .htaccess syntax is also supported by other web servers, such as Sun Java System Web Server and Zeus Web Server.

Setup :

  1. Go to /etc/httpd/conf/httpd.conf and changes
    – Options Indexes Multiviews
    – AllowOverride AuthConfig
  2. Restart the httpd service

             #service httpd restart

        3. Create the .htacces usually on the public_html folder

                # vi .htaccess

                AuthType Basic
                AuthName "Stoooop! Limited Access Choy!!!"
                AuthUserFile "/opt/test.passwd"
                Require user adityo


        4. Create the user and password

             # /usr/bin/htpasswd -c /opt/test.passwd adityo
             New password:
             Re-Type new password:
             Adding password for user adityo

         5. We can see the user and password on opt/test.passwd or the directory you set the passwd

             #cat /opt/test.passwd

        6. how to add another user on .hatccess

            #/usr/bin/htpasswd  /home/blogbin/test.passwd prie
             New password:
             Re-type new password:
             Adding password for user prie

            You can see the user on opt/test.passwd

      #cat /opt/test.passwd


    now you can try to authenticate the .htaccess on your http://localhost / web address

Leave a Reply