Handling 404 Error's With Apache - Apache and hierarchies
(Page 2 of 4 )
Apache is a very configurable web server, and it depicts a web site as a hierarchically structured set of files and directories. These directories are organized with parent-child relationships, like this:

Apache also supports configuration files knows as htaccess files. These files can be used to set various file/directory permissions, redirection attributes, and block users coming from a specific IP address, etc. Htaccess files are created with the filename ".htaccess" (notice the dot at the beginning of the filename) and can reside in any directory that an Apache server can process.
Because of the way Apache works, if I had an htaccess file saved in a directory called home and this directory also contained several sub-directories, then each sub-directory would be influenced by the htaccess file in the home directory as well.
Think of a situation in which you might want to password protect several directories on your web site; your web site may be structured with one main root directory and 23 sub-directories. By simply placing a specially designed htaccess file in the root directory, all 23 sub-directories are automatically protected as well. This is a great time-saver, because usually if you're modifying the attributes of one directory, then there's a good chance that you'd like the attributes of all of its sub-directories affected by affected as well.
Hopefully you now understand the benefits of Apache thinking in terms of a hierarchy. We can use this hierarchical structure to our benefit by creating a htaccess file that can trap 404 errors and redirect the user to the appropriate page or perform some specific action depending on the URL that the visitor typed in. Let's do that now.
Next: Implementing a 404 trap >>
More Apache Articles
More By John Ferme