| What
can I do with the
.htaccess file and
what is it ?
The .htaccess file
is an ASCII text
document that can
be placed in any
directory on your
site. It can be
used to control
access to files
and directories,
and customize some
server operation
in your site. A
.htaccess file can
be created in any
word processor but
must be saved as
text only. You must
use FTP software
in ASCII mode to
upload or edit your
.htaccess file.
For the examples
provided here, place
the .htaccess file
in your root directory.
If you use frontpage
do not modify the
.htaccess because
it will mess up
your site!
Some examples of
the uses are shown
here.
Custom Error Messages
Add the following
to the .htaccess
file::
ErrorDocument 404
/notfound.html
After "ErrorDocument" specify
the error code,
followed by
a space, and then
the path and
filename
of the .html file
you would like
to
be displayed when
the specified
error
is generated.
Denying User Access
Add the following
to the .htaccess
file:
order allow,deny
deny from 128.23.45.
deny from 207.158.255.213
allow from all
This is an example
of a .htaccess file
that will block
access to your site
to anyone who is
coming from any
IP address beginning
with 128.23.45 and
from the specific
IP address 207.158.255.213
. By specifying
only part of an
IP address, and
ending the partial
IP address with
a period, all sub-addresses
coming from the
specified IP address
block will be blocked.
You must use the
IP addresses to
block access, use
of domain names
is not supported.
Password protecting
directories.
The file .htaccess.
This file should
be in the directory
which contains the
documents to restrict
access to. The contents
of this file specify
the name of the
password file.
For
example if you
were user username
with web documents
in the local
directory "/home/yourname/public_html/members" that
you wanted to
restrict access
to, your .htaccess
might look like:
AuthUserFile /home/yourname/public_html/members/.htpasswd
AuthName Members
Only
AuthType Basic
require valid-user
Note that .htaccess
will not work if
there are extra
spaces after AuthUserFile.
The file .htpasswd.
This file contains
the passwords of
the users.
To create the .htpasswd
file log in to this
server using telnet,
change directory
to the directory
you want to restrict
access to, and type:
htpasswd -c .htpasswd
someuser
for the first user
(where someuser
is the username).
You will then be
prompted twice for
the user's password.
The -c option causes
the .htpasswd file
to be created. For
each additional
user type:
htpasswd .htpasswd
someuser
Other examples can
be found at http://www.apache.org

|