Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • Password Protect Website Directory Using .htaccess File

    • 0
    • 1
    • 1
    • 1
    • 0
    • 0
    • 0
    • 0
    • 126
    Comment on it

    Hello Reasders

    Here, we protect the directory using .htaccess file

    Before doing this, we will first need to create a .htaccess file(.htaccess file is the configuration file for the Apache HTTP server) which can be used to affect the directory and subdirectory.

    It can also be used to hide your site when it is in maintenance mode or under construction.So,now we use the passsword protect directory using .htaccess file

    The given below code use at the end of your .htaccess file to protect the user directory.

    AuthType Basic
    AuthName "Please enter username and password to access the page"
    AuthUserFile /path/to/your/directory/.htpasswd
    require valid-user
    

    Here, below we explain the type of code:

    1> AuthType

    It is one of the directive and is used to authenticate the user. The AuthType tells the server what sort of processing is in use, and "Basic" is the most common and perfectly adequate for almost any purpose.

    2> AuthName

    It is another directive which is used to identify the user when user enter the username and password. This file contains the username and password which would be required by user to access the protected page. It should be in a predefined format i.e. username:password

    3> AuthUserFile

    It defines where to look for passwords. You create the password file with the htpasswd command.

    4> require

    require directive is used to identifying who has access the directory tree. The basic usages are to control access for any valid user, a list of users, or list of groups.

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: