|
|
 |
|
 |
|
|
htaccess
1: When a user access's a protected directory, their browser
will prompt them for correct authentication.
AllowOverRide AuthConfig
The "AuthConfig" directive is required in httpd.conf for .htaccess use.
If you want it to work on all directories, add it to the main "Directory" container.
Edit httpd.conf and search for the main "/" settings.
Below is the section you are searching for.
.htaccess is able to deny the remote web browser access to a specific directory/file
unless the user has entered a valid login.
The Server is now setup to use .htaccess files.
Now you need to allow a user, or group of users.
First, we will enable a single user.
The .ht files
Two files are involved: .htaccess .htpasswd
NOTE: httpd.conf has settings to deny access to .ht* files.
From HTTPD.CONF
Example
We will assume the user "joe" wants to secure the directory "log".
His directory on the server is:
"/home/joe/www/"
The directory, "log", that he wishes to secure, has the path:
"/home/joe/www/log"
In the "log" directory, we place the files we want to secure.
In this directory will also be placed the ".htpasswd & .htaccess" files
Create The Password File
The program "htpasswd" is used to create username and passwords.
It is located in "/usr/local/apache/bin" and comes by default with Apache httpd.
This file may be elsewhere depending on your Apache install options.
"./htpasswd -c /home/joe/www/log/.htpasswd username"
A file will be created containing the username & password you input.
Type "./htpasswd" to view the syntax.
Man Page: htpasswd
Launch your text editor and input the text below.
Save the file as .htaccess and place it in the "log" directory.
The .htaccess file will look like this:
.htaccess
AuthName takes a single argument.
If "AuthName" contains spaces, it must
be enclosed in quotation marks.
The ".htaccess" file specifies the directory:
"/home/joe/www/log"
This is where we created the ".htpasswd" file.
2: Custom Error Messages
htaccess is used for more than just access restrictions.
For example, one could use htaccess to set: "custom error documents"
|
apache apache2 apache apache2 apache apache apache2 apache apache apache apache apache2 apache apache apache apache apache apache
|