The function of the. htaccess file in Apache
-The. htaccess file (or distributed configuration file) provides a way to configure changes to the directory, that is, to place a file containing one or more directives in a specific document directory to function in this directory and all its subdirectories. As a user, the commands you can use are limited. The administrator can set it through the Apache allowoverride directive.
-directives in subdirectories overwrite instructions in higher-level directories or primary server configuration files.
-. htaccess must be uploaded in ASCII mode, preferably with the permissions set to 644.
Locating the wrong document
Common Client Request error return code:
401 Authorization Required
403 Forbidden
404 Not Found
405 Method Not allowed
408 Request Timed out
411 Content Length Required
412 Precondition Failed
413 Request Entity Too Long
414 Request URI Too Long
415 Unsupported Media Type
Common Server error return code:
Internal Server Error
Users can use. htaccess to specify their own prepared Error alert page. In general, people can set up a directory specifically, such as errors to place these pages. And then again. htaccess, add the following instructions:
ErrorDocument 404/errors/notfound.html
ErrorDocument 500/errors/internalerror.html
A single line of instructions. The first instruction above means that the page is displayed as a notfound.html page in the/errors directory for 404, which is when the required document is not found. It is not difficult to see that the syntax format is:
ErrorDocument error code/directory name/filename. extension
If you need to be prompted with very little information, you don't have to create a page to use the HTML number directly in the instruction, such as the following example:
ErrorDocument 401 "<body bgcolor= #ffffff >