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

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

问题描述

为什么这项工作:

 重写规则(+)/ $ $ 1
 

和这部作品:

 重写规则(+)/ $ $ 1 [L] #bla BLA BLA
 

但这不起作用:

 重写规则(+)/ $ $ 1 #bla BLA BLA
 

解决方案

注释在.htaccess必须的开始的用

最后一个规则不起作用,因为评论是不是真正的意见。 htaccess的评论的必须开始的用(必须在一行的开始),而不是随意的任何地方。

在第二种情况下, #bla BLA BLA 是PTED作为一个第四个参数间$ P $的重写规则指令,它会被忽略。

在过去的情况下, #bla BLA BLA 是PTED作为第三个参数,除$ P $这在重写规则的情况是标志去了, #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 begin with a #.

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天全站免登陆