php-Apache Mod Rewrite:带有L参数的RewriteRule.怎么了?

我正在开发一个PHP应用程序,而Apache和Mod Rewrite有一个小问题.有人知道这是怎么回事吗?:

RewriteEngine on
RewriteBase /mysite/
RewriteRule ^css\/css\.css css/css.PHP [L]
RewriteRule ^js\/js\.js js/js.PHP [L]
RewriteRule !^img\/.* index.PHP

当我把http://localhost/css/css.css出现在index.PHP时,也许我缺少了一些东西…
为什么当url与第一个规则apache匹配时,不停止重写过程?

‘last|L’ (last rule)

Stop the rewriting process here and
don’t apply any more rewriting rules.
This corresponds to the Perl last
command or the break command from the
C language. Use this flag to prevent
the currently rewritten URL from being
rewritten further by following rules.
For example, use it to rewrite the
root-path URL (‘/’) to a real one,
e.g., ‘/e/www/’.

自3个小时以来,我已经阅读了论坛和文档,但我仍然遇到同样的问题.

提前致谢.

解决方法:

Centauro12的问题是[L]标志实际上停止了通过以下规则的传播,但随后(如果您在.htaccess文件中)URL映射重新开始.也就是说,您的所有规则都将再次处理.有关详细信息,请参见Apache Rewrite Guide.

因此,您需要显式禁用重写的PHP脚本的重写:

RewriteRule ^css/css.PHP - [L]
RewriteRule ^js/js.PHP - [L]

或更紧凑(尽管可能不是您想要的):

# don't rewrite anything that really exists
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule .* - [L]

相关文章

统一支付是JSAPI/NATIVE/APP各种支付场景下生成支付订单,返...
统一支付是JSAPI/NATIVE/APP各种支付场景下生成支付订单,返...
前言 之前做了微信登录,所以总结一下微信授权登录并获取用户...
FastAdmin是我第一个接触的后台管理系统框架。FastAdmin是一...
之前公司需要一个内部的通讯软件,就叫我做一个。通讯软件嘛...
统一支付是JSAPI/NATIVE/APP各种支付场景下生成支付订单,返...