网址改写Zeus - 正则表达式的帮助

时间:2010-10-04 12:33:35

标签: regex mod-rewrite zeus

我已经登陆了一个令人尴尬的任务,即今天放置一个网站只是为了发现它不是在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 / in的任何链接,但排除那些/ blog / css,/ blog / js和/ blog / images。但它不是><

2 个答案:

答案 0 :(得分:0)

我不知道Zeus重写(我从未听说过该产品)但只要有经验的用户没有答案:根据this blog post,可以在Zeus中嵌套规则

的某些内容可能会在/ blog / css中关闭重写:

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

  ... your 404 rewrite rule here

endif;

这是受过教育的猜测,但如果我正确理解语法,那就不会太离谱了。

答案 1 :(得分: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
相关问题