[英]Redirect using Rewrite module IIS7
我一直在從IIS資源中遵循以下文章的步驟,以便在IIS7上使用重寫模塊2.0使用基於以下正則表達式的模式捕獲源URL並提供目標,以設置永久重定向。
http://learn.iis.net/page.aspx/461/creating-rewrite-rules-for-the-url-rewrite-module
源(舊)URL: http://xx.xx.xxx.xx/term/product/term-term/category/example-123/58276模式:http://xx.xx.xxx.xx/term/( [az] +)/([az-] +)/([az] +)/([0-9a-z-] +)/([0-9] +)
在IIS7中測試源URL的模式可以正常工作。 如下所示的目標URL需要維護IP,后跟是/ product的R:1和/ 582276這是R:5
目標網址: http://xx.xx.xxx.xx/ {R:1} / {R:5}因此,實際的目標(NEW)URL為http://xx.xx.xxx.xx/product/58276
但是,當使用瀏覽器並獲取煩人的404時,上述方法不起作用。
我的web.config看起來像
`
<rules>
<rule name="PatternRedirect" stopProcessing="true">
<match url="http://xx.xx.xxx.xx/term/([a-z]+)/([a-z-]+)/([a-z]+)/([0-9a-z-]+)/([0-9]+)" />
<action type="Redirect" url="http://xx.xx.xxx.xx/{R:1}/{R:5}" />
</rule>
</rules>
</rewrite>
<httpRedirect enabled="true" destination="" exactDestination="true" httpResponseStatus="Permanent" />
`
有任何想法嗎?
謝謝
模式匹配的輸入值是URL的路徑部分,不包括前導/
(正斜杠)。 match元素的url屬性必須以“ term”開頭:
<match url="term/([a-z]+)/([a-z-]+)/([a-z]+)/([0-9a-z-]+)/([0-9]+)" />
如果要確保該規則僅適用於xx.xx.xxx.xx主機請求,請添加條件:
<conditions logicalGrouping="MatchAll">
<add input="{HTTP_HOST}" pattern="^xx.xx.xxx.xx$" />
</conditions>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.