2010-10-04 35 views
0

我已經登陸與今天讓一個網站生活的不值得羨慕的任務只是爲了找出它不在Apache上運行,而是使用宙斯。現在這相當混亂地打破了我的mod_rewrite腳本。網址重寫爲宙斯 - 正則表達式的幫助

它是一個簡單的腳本,我已經重寫了到宙斯格式:

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

成爲

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

但是,不足之處是,而我在一些子目錄的關斷的mod_rewrite(例如CSS,圖像等)我不能在宙斯做這個。

一直在玩正則表達式試圖獲得上述正則表達式來排除/ blog/css /或/ blog/images的任何匹配,但沒有運氣。

希望有人能幫助我!

編輯。目前正在對這個正則表達式...

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

因此,這應與/博客的任何鏈接/中但不包括那些有/博客/ CSS,/博客/ JS和/博客/圖片。但它不> <

回答

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 
0

我不宙斯的想法重寫(我從來沒有聽說過的產品),但只要沒有從有經驗的用戶回答:根據this blog post,它是可以嵌套規則在宙斯。

東西沿着這些線路威力工作,關閉改寫/博客/ CSS:

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

    ... your 404 rewrite rule here 

endif; 

這是受過教育的猜測,但如果我理解正確的語法,它shoudln't太遙遠。

+0

這一工程,並會排除/博客/ CSS中的文件,但它抓住了網站上所有其他文件。我真正需要的是一個正則表達式,它匹配/ blog///blog/css /,/ blog/images /和/ blog/js / – DMA 2010-10-05 06:29:19