From: Rich Bowen
In general, you should never use .htaccess files unless
you don't have access to the main server configuration file. There is,
- for example, a prevailing misconception that user authentication should
- always be done in .htaccess files. This is simply not the
+ for example, a common misconception that user authentication should
+ always be done in .htaccess files, and, in more recent years,
+ another miscomception that mod_rewrite directives
+ must go in .htaccess files. This is simply not the
case. You can put user authentication configurations in the main server
configuration, and this is, in fact, the preferred way to do
- things.
mod_rewrite directives work better,
+ in many respects, in the main server configuration.
.htaccess files should be used in a case where the
content providers need to make configuration changes to the server on a
@@ -155,6 +158,15 @@ changes on a per-directory basis.
.htaccess files were enabled for /, which
is not usually the case.)
+ In the case of RewriteRule directives, in
+ .htaccess context these regular expressions must be
+ re-compiled with every request to the directory, whereas in main
+ server configuration context they are compiled once and cached.
+ Additionally, the rules themselves are more complicated, as one must
+ work around the restrictions that come with per-directory context
+ and mod_rewrite. Consult the Rewrite Guide for more
+ detail on this subject.
The second consideration is one of security. You are permitting users to modify server configuration, which may result in changes over which you have no control. Carefully consider whether you want to give diff --git a/docs/manual/howto/htaccess.xml b/docs/manual/howto/htaccess.xml index ccddcc8c1fc..b560f1df853 100644 --- a/docs/manual/howto/htaccess.xml +++ b/docs/manual/howto/htaccess.xml @@ -124,11 +124,14 @@ changes on a per-directory basis.
In general, you should never use .htaccess files unless
you don't have access to the main server configuration file. There is,
- for example, a prevailing misconception that user authentication should
- always be done in .htaccess files. This is simply not the
+ for example, a common misconception that user authentication should
+ always be done in .htaccess files, and, in more recent years,
+ another miscomception that .htaccess files. This is simply not the
case. You can put user authentication configurations in the main server
configuration, and this is, in fact, the preferred way to do
- things.
mod_rewrite directives work better,
+ in many respects, in the main server configuration.
.htaccess files should be used in a case where the
content providers need to make configuration changes to the server on a
@@ -179,6 +182,17 @@ changes on a per-directory basis.
.htaccess files were enabled for /, which
is not usually the case.)
+ In the case of .htaccess context these regular expressions must be
+ re-compiled with every request to the directory, whereas in main
+ server configuration context they are compiled once and cached.
+ Additionally, the rules themselves are more complicated, as one must
+ work around the restrictions that come with per-directory context
+ and mod_rewrite. Consult the Rewrite Guide for more
+ detail on this subject.
The second consideration is one of security. You are permitting users to modify server configuration, which may result in changes over which you have no control. Carefully consider whether you want to give