Articles – Enabling .htaccess on Apache

Enabling .htaccess on Apache

1. Look for AllowOverride and Set it to All in your apache.conf. apache.conf is normally in

#
# AllowOverride controls what directives may be placed in .htaccess files.
# It can be “All”, “None”, or any combination of the keywords:
# Options FileInfo AuthConfig Limit
#
AllowOverride All

2. Create a blank .htaccess file in the directory you want to protect.

3. Then vi this .htaccess, remember to set your path for .htpasswd, this is your password file.

AuthName “Restricted Area”
AuthType Basic
AuthUserFile /path/to/.htpasswd
AuthGroupFile /dev/null

<Limit GET POST>
require valid-user
</Limit>

4. Generate your .htpasswd file

Simple way – Go to http://www.quentinsagerconsulting.com/utilities/htpasswd.php

DIY way –

htpasswd -c .htpasswd user_name <user name can be any name and does not need to be created locally on the linux machine>
Enter the preferred password twice and it’s done. To add more users, do not use the -c variable, instead use simply:

htpasswd .htpasswd new_name

That’s it.

Pages

Sidebar Block

* Function Not Configured *

Archives