什么是L的[QSA,L] htaccess的 [英] What is L in [QSA, L] in htaccess

查看:385
本文介绍了什么是L的[QSA,L] htaccess的的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

QSA意味着,如果有通过与原来的URL的查询串,   它会被追加到重写(欧莱?P = 1将被改写为   ?的index.php URL =欧莱和放大器; P = 1

QSA means that if there's a query string passed with the original URL, it will be appended to the rewrite (olle?p=1 will be rewritten as index.php?url=olle&p=1.

L表示,如果规则匹配,不处理任何更多的规则集以下   这一个。

L means if the rule matches, don't process any more RewriteRules below this one.

什么都是一些简单的例子来讲解使用的L? 我似乎无法掌握上述这样的解释。任何帮助将是非常美联社preciated。 谢谢。

Hi, what are some easy examples to explain the use of L? I can't seem to grasp this explanation above. Any help will be highly appreciated. Thanks.

推荐答案

QSA 标志表示要追加在的URI中现有的查询字符串的已被重写。例如:

The QSA flag means to append an existing query string after the URI has been rewritten. Example:

URL = http://example.com/foo/bar?q=blah

规则:

RewriteRule ^foo/(.*)$ /index.php?b=$1

结果= /index.php?b=bar

请注意 Q =等等走了。由于现有的查询字符串被删除赞成一个在规则的目标,(B = $ 1)的。现在,如果你有一个 QSA 标记:

Notice how the q=blah is gone. Because the existing query string is dropped in favor of the one in the rule's target, (b=$1). Now if you include a QSA flag:

RewriteRule ^foo/(.*)$ /index.php?b=$1 [QSA]

的结果变成= /index.php?b=bar&q=blah

标志仅仅意味着停止应用该遵循任何规则。由于相同的URL, http://example.com/foo/bar?q=blah ,并给出了规则:

The L flag simply means to stop applying any rules that follow. Given the same URL, http://example.com/foo/bar?q=blah, and given the rules:

RewriteRule ^foo - 

RewriteCond %{REQUEST_URI} !^/bar.php
RewriteRule ^(.*)$ /bar.php?z=$1 

第一条规则被应用和URI被改变地通过(通过 - 目标)。重写引擎然后处理下一条规则,并且URI被改写为 /bar.php?z=foo/bar 。当您添加一个→会发生什么来结束:

The first rule gets applied and the URI gets passed through unchanged (via the - target). The rewrite engine then processes the next rule, and the URI gets rewritten to /bar.php?z=foo/bar. What happens when you add an L to the end:

RewriteRule ^foo - [L]

RewriteCond %{REQUEST_URI} !^/bar.php
RewriteRule ^(.*)$ /bar.php?z=$1 

网址 http://example.com/foo/bar 被通过非接触传递的第一条规则,然后点击停止,因为 标志。如果URL是 http://example.com/something/else 那么第一个规则不匹配,第二条规则被应用,重写的URI: /bar.php?z=something/else

The URL http://example.com/foo/bar gets passed through untouched from the first rule, then stops because of the L flag. If the URL is http://example.com/something/else then the first rule doesn't match and the second rule gets applied, rewriting the URI to: /bar.php?z=something/else

请注意,由于重写引擎通过所有的规则一直循环到URI停止变化,在标志的没有的prevent的从当前迭代得到应用循环,只有进一步的规则。

Note that since the rewrite engine loops through all the rules until the URI stops changing, the L flag will not prevent the looping, only any further rules from getting applied in the current iteration.

这篇关于什么是L的[QSA,L] htaccess的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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