0

我已经完成了一项令人羡慕的任务,即今天上线一个站点,却发现它没有在 Apache 上运行,而是在使用 Zeus。现在这会相当混乱地破坏我的 mod_rewrite 脚本。

它是一个简单的脚本,我已将其重写为 Zeus 格式:

RewriteEngine on
RewriteRule !404.php$ blog/404.php [L]

变成

match URL into $ with ^/blog/(.*)           
if matched set URL=/blog/404.php

然而,不利的一面是,虽然我在某些子目录(例如 css、图像等)中关闭了 mod_rewrite,但我无法在 Zeus 中执行此操作。

一直在玩正则表达式以尝试获取上述正则表达式以排除 /blog/css/ 或 /blog/images 的任何匹配项,但没有运气。

希望那里有人可以帮助我!

编辑。目前正在研究这个正则表达式......

^(?=/blog/)((?!css/|images/|js/).)*$ 

所以这应该匹配任何带有 /blog/ 的链接,但不包括带有 /blog/css、/blog/js 和 /blog/images 的链接。但是没有><

4

2 回答 2

0

我不知道 Zeus 重写(我什至从未听说过该产品),但只要没有经验丰富的用户的回答:根据这篇博客文章,可以在 Zeus 中嵌套规则。

沿着这些思路可能会关闭 /blog/css 中的重写:

match URL into $ with ^/blog/css/(.*)           
if not matched 

  ... your 404 rewrite rule here

endif;

这是有根据的猜测,但如果我正确理解语法,它应该不会太远。

于 2010-10-04T13:25:36.843 回答
0

好吧,在尝试了很多正则表达式之后,我选择了 KISS 并想出了这个。希望它可以帮助某人

 match URL into $ with ^/blog/(.*)$   
if matched 
match URL into $ with ^/blog/css/(.*)$
if not matched
match URL into $ with ^/blog/images/(.*)$
if not matched
match URL into $ with ^/blog/js/(.*)$
if not matched 
    set URL=/blog/404.php
endif
endif
endif
endif
于 2010-10-08T10:16:25.443 回答