0

我有这个重写规则

RewriteRule (.*)/([^/\.]+).css$ include/style/styleRedir.php?css=$2.css [L,NC]

与以下内容匹配:

某个文件夹/foo.css

并将它们重写为:

包括/样式/styleRedir.php?css=foo.css

但是它不匹配:

foo.css

所以我尝试将其更改为:

RewriteRule (.*)(/?)([^/\.]+).css$ include/style/styleRedir.php?css=$3.css [L,NC]

但随后它将重写为:

包括/样式/styleRedir.php?css=.css

那么我怎样才能制作这个 RewriteRule 以便它可以重写 foo.css 以包含/style/styleRedir.php?css=foo.css

4

1 回答 1

4

我没有安装 Apache 来测试,但你有没有尝试添加 /?到第一组?

RewriteRule (.*/?)([^/\.]+).css$ include/style/styleRedir.php?css=$2.css [L,NC]

或者,为什么不是 2 条规则?

RewriteRule (.*)/([^/\.]+).css$ include/style/styleRedir.php?css=$2.css [L,NC]
RewriteRule /?([^/\.]+).css$ include/style/styleRedir.php?css=$1.css [L,NC]
于 2008-12-08T20:24:43.180 回答