[Bug 70032] New: Guide to Apache mod_rewrite: complexity
[email protected] Fri, 08 May 2026 18:24:35 +0000
| Newsgroups | gmane.comp.apache.documentation |
|---|---|
| Message-ID | <[email protected]/bugzilla/> |
https://bz.apache.org/bugzilla/show_bug.cgi?id=70032
Bug ID: 70032
Summary: Guide to Apache mod_rewrite: complexity
Product: Apache httpd-2
Version: 2.5-HEAD
Hardware: All
URL: https://httpd.apache.org/docs/trunk/en/rewrite/
OS: All
Status: NEW
Severity: minor
Priority: P3
Component: Documentation
Assignee: [email protected]
Reporter: [email protected]
Target Milestone: ---
The Guide to Apache mod_rewrite contains:
> Since mod_rewrite is so powerful, it can indeed be rather complex.
For its part, Apache mod_rewrite Introduction contains:
> The Apache module mod_rewrite is a very powerful and sophisticated module which provides a way to do URL manipulations. With it, you can do nearly all types of URL rewriting that you may need. It is, however, somewhat complex, and may be intimidating to the beginner. There is also a tendency to treat rewrite rules as magic incantation, using them without actually understanding what they do.
I hate to judge the complexity of something I do not master, but I’m afraid
calling mod_rewrite “rather” or “somewhat” complex is an understatement. I
created my first website nearly 3 decades ago, have been administrating httpd
instances for more than 2 decades, have a CS bachelor's degree, have worked as
a fulltime full-stack developer―often as administrator―for a couple decades,
and I started dealing with mod_rewrite specifically > 1½ decades ago, yet I
still do not understand it well (although of course I only dealt with
mod_rewrite for a couple person-weeks at best during that period).
I believe mod_rewrite should be called simply “complex” or “complicated”. But
regardless of sugar-coating, its complexity should not be attributed simply to
its power. Rich Bowen described mod_rewrite as “very temperamental”:
https://lists.apache.org/thread/94gh4txmxnt8y4bknz9p8p4ygnot08sq
Rich wrote a mod_rewrite book of more than 100 pages (much of which is
thankfully dedicated to guide about using that power, not just specifying):
https://mod-rewrite.org/
Terry Ellisons wrote in 2012 that he had “been fighting the intricacies of
rewrite rules for years”, commenting:
> Apache is extremely weak explaining how rewriting works for this use case. For example it does not provide a clear explanation of what PerDir .htaccess file is selected and why. It does not explain the intricacies of PerDir cycling and how to avoid this.
https://serverfault.com/a/349938/370849
The Apache 1.3 URL Rewriting Guide read:
> In other words: With mod_rewrite you either shoot yourself in the foot the first time and never use it again or love it for the rest of your life because of its power.
https://docs.oracle.com/cd/B13789_01/server.101/q20201/misc/rewriteguide.html
The 2.0 doc's introduction contained:
>`` Despite the tons of examples and docs, mod_rewrite is voodoo. Damned cool voodoo, but still voodoo. ''
> -- Brian Moore
> But all this functionality and flexibility has its drawback: complexity. So don't expect to understand this entire module in just one day.
https://httpd.apache.org/docs/2.0/en/rewrite/
But the most interesting must be our FAQ:
> Why is mod_rewrite so difficult to learn and seems so complicated?
>
> Hmmm... there are a lot of reasons. First, mod_rewrite itself is a powerful module which can help you in really all aspects of URL rewriting, so it can be no trivial module per definition. To accomplish its hard job it uses software leverage and makes use of a powerful regular expression library by Henry Spencer. And regular expressions itself can be difficult to newbies, while providing the most flexible power to the advanced hacker.
>
> On the other hand mod_rewrite has to work inside the Apache API environment and needs to do some tricks to fit there. For instance the Apache API really was not designed for URL rewriting at the .htaccess level of processing. Or the problem of multiple rewrites in sequence, which is also not handled by the API per design. To provide this features mod_rewrite has to do some special (but API compliant!) handling which leads to difficult processing inside the Apache kernel. While the user usually doesn't see anything of this processing, it can be difficult to find problems when some of your RewriteRules seem not to work.
https://cwiki.apache.org/confluence/pages/viewpage.action?pageId=115522309#FAQ-Whyismod_rewritesodifficulttolearnandseemssocomplicated?
I do not know httpd internals and cannot confirm which role architecture plays
in the problem, but while it is clear that regular expressions and power bring
major inherent complexity, a huge share of the issue comes from:
1. configuration
2. the proliferation and quality of resources needed to understand
configuration
3. the tools available to debug that configuration.
🅭🄍: https://www.philippecloutier.com/Common+infrastructure+licensing#its
--
You are receiving this mail because:
You are the assignee for the bug.