阿帕奇重写规则, - (破折号)作为替代 [英] Apache RewriteRule, - (dash) as substitution

查看:135
本文介绍了阿帕奇重写规则, - (破折号)作为替代的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我经常看到在PHP MVC应用一个Apache重写规则,看起来像这样:

I often see in PHP MVC applications an Apache RewriteRule that looks like this:

RewriteRule ^.*$ - [NC,L]

在Apache的文档说:

The docs on Apache say:

一个破折号表示没有替代
  应执行(现有路径
  经过传递后保持不变)。这是
  使用时,一个标志(见下文)需要
  在不改变路径施加

A dash indicates that no substitution should be performed (the existing path is passed through untouched). This is used when a flag (see below) needs to be applied without changing the path.

所以,从我收集,你可以用它来改变使用国旗即[NC]的规则集以遵循的路径?

So from what I gather, you can use this to transform a path using a flag i.e [NC] for the RewriteRules to follow?

可能有人请解释这个破折号重写规则更好一点?

Could someone please explain this dash RewriteRule a little better?

推荐答案

看到这个答案:

<一个href=\"http://stackoverflow.com/questions/2102128/mod-rewrite-what-does-this-rewriterule-do/2102189#2102189\">mod_rewrite:这是什么重写规则呢?

这基本上意味着什么也不做,如果previous RewriteConds的比赛。接下来的重写规则(S)将转而做其他事情的时候RewriteConds不匹配。在后的情况下,我联系你,下一个重写规则重写URL包括的index.php。

It essentially means "do nothing if the previous RewriteConds match". The next RewriteRule(s) will instead do something else when the RewriteConds don't match. In the case of the post i linked you to, the next RewriteRule rewrites the url including "index.php".

这篇关于阿帕奇重写规则, - (破折号)作为替代的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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