Skip to content

Htaccess

Htaccess

  1. htaccess is a way to password protect directories. It can also be used to give user or group specific access to directories.

  2. Now that the directory and its subdirectories are htaccess enabled, you’ll need to setup the actual files.

    Create a file in the dir you want to protect called .htaccess

    Here’s an example .htaccess file:

    AuthUserFile /var/www/.htpasswd AuthName "Authorization Required" AuthType Basic <Limit GET POST> require valid-user #you can use require user site1, #where site1 is the username in this machine </Limit>
  3. Now that .htaccess is set up, you’ll need to create the password file. To do this, use the program htpasswd.

    To create an initial .htpasswd file, use the -c tag.

    The syntax is: htpasswd passwordfilename user (add -c if you’re creating the file)

  4. So, we would use:

    htpasswd -c /var/www/.htpasswd username

    It would then prompt me for a password. To create new users in the same file, simply drop the -c.

    htpasswd /var/www/.htpasswd anotherusername

    Enter the password to confirm. Now, everything should be set up, and your directory should be protected.

Categories: Lesson, Linux, Server, Solution, Web Hosting.

Comment Feed

No Responses (yet)



Some HTML is OK

or, reply to this post via trackback.