A # only starts a comment at the beginning of a line. Text after a directive's arguments is not ignored — it is passed to the directive as more arguments.
Apache does not read that trailing text as a note to the reader. It reads it as additional arguments to RewriteRule, and either misbehaves or refuses to parse the file — which returns 500 for every URL under the directory.
Move the comment to its own line above the directive.
Note that a # inside a pattern or a URL is fine — it is only a problem when a separate word beginning with # follows the directive's arguments. These are both correct:
Run w3id-check with --rule htaccess/no-inline-comment to check this rule on its own; without it the tool runs every rule, as the pull request checks do.
htaccess/no-inline-commentSeverity: error · Status: enforced · Applies to:
ids/**/.htaccessWhat
A
#only starts a comment at the beginning of a line. Text after a directive's arguments is not ignored — it is passed to the directive as more arguments.Why
Apache does not read that trailing text as a note to the reader. It reads it as additional arguments to
RewriteRule, and either misbehaves or refuses to parse the file — which returns 500 for every URL under the directory.Wrong
Right
How to fix
Move the comment to its own line above the directive.
Note that a
#inside a pattern or a URL is fine — it is only a problem when a separate word beginning with#follows the directive's arguments. These are both correct:How to check
Run
w3id-checkwith--rule htaccess/no-inline-commentto check this rule on its own; without it the tool runs every rule, as the pull request checks do.Testing your changes covers installing the tool, and what else is worth checking by hand.
See also
htaccess/no-flag-whitespace