向 .htaccess 添加注释 [英] Adding comments to .htaccess
问题描述
为什么这样做:
RewriteRule (.+)/$ $1
和这项工作:
RewriteRule (.+)/$ $1 [L] #bla bla bla
但这不起作用:
RewriteRule (.+)/$ $1 #bla bla bla
推荐答案
.htaccess 中的注释必须位于自己的行,不能附加到其他语句中.
最后一条规则不起作用,因为评论并不是真正的评论.htaccess 中的注释必须以 #
开头(必须在一行的开头),而不是任意位置.
Comments in .htaccess must be on their own line, not appended to other statements.
The last rule doesn't work because the comments aren't really comments. Comments in htaccess must begin with a #
(must be at the start of a line), and not arbitrarily anywhere.
在第二种情况下,#bla bla bla
被解释为 RewriteRule
指令的第四个参数,它被简单地忽略了.
In the second case, the #bla bla bla
is interpreted as a 4th parameter of the RewriteRule
directive, which is simply ignored.
在最后一种情况下,#bla bla bla
被解释为第三个参数,在 RewriteRule
的情况下是标志的位置,而 #bla bla bla
不是 mod_rewrite 理解的任何标志,因此您会收到错误.
In the last case, the #bla bla bla
is interpreted as a 3rd parameter, which in the RewriteRule
's case is where the flags go, and #bla bla bla
isn't any flags that mod_rewrite understands so you get an error.
这篇关于向 .htaccess 添加注释的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!