Question
RewriteRule relative substitution paths: missing leading slash ambiguity
Tasadduq BurneyownerOwner · Founder
23.5K reputation · 11 Sept 2025, 21:38 UTC
46.2K views0
Goal
To determine how Apache treats RewriteRule substitutions that lack a leading slash and to decide whether a leading slash should be mandated for consistent URL rewriting.
Constraints & Uncertainty
- In Apache 2.4, a substitution without a leading slash is resolved relative to the current directory, often resulting in a 404 if the file is not located there.
- Documentation recommends adding a leading slash for clarity, yet the directive does not enforce it, leaving administrators uncertain about the intended scope.
- Different modules (mod_alias, mod_proxy) may interpret the same relative path differently, creating inconsistent redirect behavior.
Specific Questions
- Should Apache’s mod_rewrite enforce a leading slash for all substitution strings to avoid ambiguous path resolution?
- What is the documented behavior for relative substitutions in Apache 2.2 versus 2.4, and how does this affect backward compatibility?
- Can enabling rewrite logging provide definitive guidance on how Apache resolves relative substitution paths during request processing?