Asp.net mvc 使用正则表达式重写IIS Url重定向到错误的目标
我必须使用正则表达式执行重定向 我必须执行以下重定向:Asp.net mvc 使用正则表达式重写IIS Url重定向到错误的目标,asp.net-mvc,redirect,iis,url-rewriting,web-config,Asp.net Mvc,Redirect,Iis,Url Rewriting,Web Config,我必须使用正则表达式执行重定向 我必须执行以下重定向: www.mysite.com/old-category/old-subcategory -> www.mysite.com/new-category/new-subcategory www.mysite.com/old-category/old-subcategory/old-page1 -> www.mysite.com/new-category/new-subcategory/new-page1 www.
www.mysite.com/old-category/old-subcategory -> www.mysite.com/new-category/new-subcategory
www.mysite.com/old-category/old-subcategory/old-page1 -> www.mysite.com/new-category/new-subcategory/new-page1
www.mysite.com/old-category/old-subcategory/old-page2 -> www.mysite.com/new-category/new-subcategory/new-page2
...
www.mysite.com/old-category/old-subcategory/old-pageN -> www.mysite.com/new-category/new-subcategory/new-pageN
其中,new pageN
可以是randow单词
下面是我在web.config中的规则:
<rewrite>
<rules>
...
<rule name="myCustomRule">
<match url="^old-category/old-subcategory/(.*)" ignoreCase="false" />
<action type="Redirect" url="new-category/new-subcategory/{R:1}" />
</rule>
</rules>
</rewrite>
什么都不管用。。。怎么了
谢谢你你的问题不太清楚。。。 顺便说一下
<action type="Redirect" url="/new-category/new-subcategory/{R:1}" />
或
<action type="Redirect" url="/new-category/new-subcategory/{R:1}" />
<action type="Redirect" url="http://www.example.com/new-category/new-subcategory/{R:1}" />