向.htaccess添加注释 [英] Adding comments to .htaccess

查看:160
本文介绍了向.htaccess添加注释的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为什么这样工作:

  RewriteRule(。+)/ $ $ 1 


$ b

  RewriteRule(。 +)/ $ $ 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 the RewriteRule directive, which is simply ignored.

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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆