2016-07-15 80 views
0

我在配置文件中重定向URL。這是我在做什麼:IIS Url重定向匹配模式

<rule name="award temp redirect" stopProcessing="true"> 
    <match url="(.*?)/?award.aspx$" /> 
    <action type="Redirect" url="http://www.abc.com.au/award.aspx" redirectType="Temporary" /> 
</rule> 

這是爲/award.aspx工作正常,但我想補充的/awards/award爲好。目前,我已爲/awards/award創建單獨的規則。

我可以將這兩個添加到一個匹配。如果網址是/award.aspx/award/awards則重定向到http://www.abc.com.au/award.aspx

回答

1

match接受正則表達式爲url的值。嘗試:

<match url="(.*?)/?awards?(\.aspx)?$" /> 

Regular expression visualization

這將匹配awardaward.aspxawardsawards.aspx

更新匹配/test還有:

<match url="(.*?)/?(awards?|test)(\.aspx)?$" /> 

Regular expression visualization

這僅僅是一個regular expression。你可以匹配任何你想要的。

+0

感謝如果我想添加testaward或testaward.aspx –

+0

對不起,它不是測試版我想匹配它的/ test或/test.aspx對不起,我感到困惑@lorond –

+0

@OwaisAhmed更新爲'/ test' – lorond