向.htaccess添加注释 [英] Adding comments to .htaccess
问题描述
为什么这样工作:
RewriteRule(。+)/ $ $ 1
$ bRewriteRule(。 +)/ $ $ 1 [L] #bla bla bla
p>
RewriteRule(。+)/ $ $ 1 #bla bla bla
解决方案
.htaccess中的注释必须在其自己的行 >
最后一条规则不起作用,因为注释不是真正的注释。 htaccess 中的注解必须以
#
开头(必须在一行的开头),而不是任何地方。
在第二种情况下,
#bla bla bla
被解释为RewriteRule $
在最后一种情况下,
#bla bla bla
解释为第三个参数,在RewriteRule
的情况下,标志去,#bla bla bla
不是mod_rewrite理解的任何标志,所以你得到一个错误。Why does this work:
RewriteRule (.+)/$ $1
and this work:
RewriteRule (.+)/$ $1 [L] #bla bla bla
but this doesn't work:
RewriteRule (.+)/$ $1 #bla bla bla
解决方案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.In the second case, the
#bla bla bla
is interpreted as a 4th parameter of theRewriteRule
directive, which is simply ignored.In the last case, the
#bla bla bla
is interpreted as a 3rd parameter, which in theRewriteRule
'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屋!