2012-06-14 103 views
4
<rule name="blog" stopProcessing="true"> 
     <match url="en/blog.aspx?Id=9" /> 
     <action type="Redirect" url="http://www.mynewurl.com" redirectType="Permanent" /> 
    </rule> 

我可以重定向“en/blog.aspx”,但我无法仅重定向“en/blog.aspx?Id = 9”。IIS Web.Config 301重定向查询字符串参数(?)

任何想法?

+1

你是说,你的“匹配”不匹配EN/blog.aspx编号= 9,或者,你说你无法重定向到它在你的?行动? – Jeremy

+0

该匹配不能与查询参数 –

回答

9

终于找到了解决办法:

/en/blog.aspx?Id=9会重定向到http://www.newurl.com

<rule name="blog" stopProcessing="true"> 
     <match url="en/blog.aspx$" /> 
     <conditions> 
     <add input="{QUERY_STRING}" pattern="Id=9" /> 
    </conditions> 
     <action type="Redirect" url="http://www.newurl.com" redirectType="Permanent" /> 
    </rule> 

发现这里的解决方案:301 redirect not working in IIS 7

+0

+1一起发布您的答案。 – Jeremy

+0

对于有兴趣阅读此主题的人,请参阅:[IIS URL重写和ASP.NET路由](http://learn.iis.net/page.aspx/496/iis-url-rewriting-and-aspnet -路由/) – Jeremy