Skip to content

.htaccess rules ​

Everything about the redirect rules themselves: how they are written, and where they point.

Syntax ​

These break the file. Apache refuses to parse an invalid directive, and an unparseable .htaccess returns 500 for every URL under the directory.

RuleSeverityWhat
htaccess/no-flag-whitespaceerrorNo spaces inside the [...] flag list
htaccess/space-before-flagserrorA space before the [...], or it is part of the target
htaccess/valid-rewrite-flagserrorFlag names must be ones mod_rewrite knows
htaccess/no-inline-commenterror# only starts a comment at the start of a line
htaccess/uppercase-rewrite-flagswarningWrite flags in upper case

Rules that never match ​

These do not break anything. They simply never fire, and the request falls through to a 404 with nothing in the logs to say why.

RuleSeverityWhat
htaccess/rewrite-engine-requirederrorRewriteRule does nothing without RewriteEngine on
htaccess/pattern-relative-to-direrrorNo leading slash, no repeated directory name
htaccess/anchor-patternswarningMake an optional trailing group optional
htaccess/no-greedy-capturewarning^(.+)/?$ swallows the slash
htaccess/escape-literal-dotswarning. is a wildcard; escape a literal dot

Redirect targets ​

RuleSeverityWhat
htaccess/no-open-redirecterrorNever build the target hostname from the request
htaccess/https-targetwarningRedirect to https://
htaccess/github-raw-targetwarningRaw file URLs, not /blob/ pages
htaccess/no-rawgiterrorRawGit has shut down; use jsDelivr
htaccess/no-double-slashwarningNo // in the produced URL
htaccess/no-self-redirectwarningPoint at the destination, not back at w3id.org
htaccess/avoid-permanent-redirectwarningA 301 cannot be taken back

Directives and negotiation ​

RuleSeverityWhat
htaccess/allowed-directiveserrorNo code execution, proxying, or access control
htaccess/valid-cors-headerwarningDo not copy the truncated CORS line
htaccess/no-406-fallbackwarningEnding negotiation in 406 answers nobody
htaccess/no-options-directiveproposedOptions directives — open questions

Back to the rule catalogue.