2014-03-26 174 views
0

我使用Tuckey刪除URL .xhtml擴展以下規則:Tuckey重寫:刪除擴展

<rule> 
    <from>^/?([a-z-]+)/$</from> 
    <to>/$1.xhtml</to> 
</rule> 

<rule> 
    <from>^/?([a-z-]+)$</from> 
    <to>/$1.xhtml</to> 
</rule> 

所以/頁/和/頁被映射到/page.xthml

但是,如果我有/目錄/頁/這不映射到/directory/page.xhtml。

回答

0
<rule> 
    <from>^/?([a-z-/]+)/$</from> 
    <to>/$1.xhtml</to> 
</rule> 

<rule> 
    <from>^/?([a-z-/]+)$</from> 
    <to>/$1.xhtml</to> 
</rule> 

我加斜槓成可重複的字符列表和這個工作

0

使用這樣的規則:

<rule> 
    <from>^/?[a-z-]*?/?([a-z-]+)/$</from> 
    <to>/$1.xhtml</to> 
</rule> 

<rule> 
    <from>^/?[a-z-]*?/?([a-z-]+)$</from> 
    <to>/$1.xhtml</to> 
</rule> 
+0

這是爲什麼比我已經貼出答案更好?另外,這是什麼如果url是/目錄/目錄/頁面? –

+0

它會允許我知道零次或多次,你的將允許零次或一次,讓OP決定什麼適合他:) – aelor