2010-03-18 31 views
0

我需要一些web.config中示例爲以下各表達種類:UrlRewriter.net表達式示例

$number

由組號數匹配的最後一個子字符串。

$<name>

的最後一個子由匹配名爲name組(?<名>)相匹配。

${property}

當表達式求值的屬性的值。

${transform(value)}

調用指定值的變換的結果。

${map:value}

映射使用地圖指定的值的結果。如果不存在映射,則替換爲空字符串。

${map:value|default}

映射使用地圖指定的值的結果。如果不存在映射,則替換爲默認值。

樣品:

<rewriter> 
    <if url="/tags/(.+)" rewrite="/tagcloud.aspx?tag=$1" /> 
    <!-- same thing as <rewrite url="/tags/(.+)" to="/tagcloud.aspx?tag=$1" /> --> 
</rewriter> 

非常感謝您!

回答

1

這是我發現/猜測。未經測試。

$號:http://urlrewriter.net/index.php/support/using

<rewrite url="^(.*)/(\?.+)?$" to="$1/default.aspx$2?" /> 

$1 matches (.*) 
$2 matches (\?.+) 

$ <名>:這個我不是正則表達式那麼肯定,在文檔中找不到任何

<rewrite url="^(?<group1>(.*))/(\?.+)?$" to="$<group1>/default.aspx$2?" /> 

$<group1> matches 

$ {}財產:http://urlrewriter.net/index.php/support/reference/actions/set-property

<set property="branch" value="$3" /> 
<rewrite to="/showbranch.aspx?branch=${branch}" /> 

$ {transform(value)}:http://urlrewriter.net/index.php/support/reference/transforms

<set property="transform-name" value="lower" /> 
<set property="value-to-transform" value="THIS WAS UPPER CASE" /> 

<redirect to="/WebForm1.aspx?q=${encode(${${transform-name}(${value-to-transform})})}" /> 

results in "/WebForm1.aspx?q=this+was+upper+case" 

$ {圖:值}:http://urlrewriter.net/index.php/support/reference/transforms/static

<mapping name="areas"> 
    <map from="sydney" to="1" /> 
    <map from="melbourne" to="2" /> 
    <map from="brisbane" to="3" /> 
</mapping> 

<rewrite to="/area.aspx?area=${areas:$3}" /> 

results in "/area.aspx?area=brisbane" 

$ {圖:值|默認}

<mapping name="areas"> 
    <map from="sydney" to="1" /> 
    <map from="melbourne" to="2" /> 
    <map from="brisbane" to="3" /> 
</mapping> 

<rewrite to="/area.aspx?area=${areas:$4|perth}" /> 

results in "/area.aspx?area=perth"