Context and processing order
The following context specifiers are used in this documentation:
- server config —
This indicates that directive can be used in global httpd.conf configuration file but not within any section like <VirtualHost> or <Directory>.
It is not allowed in .htaccess files at all.
- virtual host —
This means directive may appear inside <VirtualHost> containers.
- directory —
This mark indicates directive is valid inside <Directory>,
<Location>, <Files> containers and their regular expression equivalents.
- .htaccess —
Directive marked with this context can appear inside per-directory
RewriteRule directive is used inside .
configuration files it will automatically strip the local directory prefix
from the path and apply rules only to the remainder. You can use RewriteBase
directive to explicitly specify a base path for the rules.
While directives within one section always apply simultaneously, it is important
to understand the order of application of each section because it may have effect
on a final result. So the order of application is as follows:
<Directory> (except regular expressions). Multiple
sections can be applied to a single request. If multiple (non-regular expression)
<Directory> sections match the directory (or one of its parents) containing
a document, then the directives are applied in the order of shortest match
.htaccess files are applied from parent to descendant.
<FilesMatch> are executed simultaneously.
<LocationMatch> are executed simultaneously.
Sections and directives inside
<VirtualHost> sections are applied after
the corresponding sections and directives outside the virtual host definition.
<VirtualHost> section can apply to request at a time. Later sections
override earlier ones.
Related articles and topics