2010-03-30 86 views
2

我需要在运行IIS的ASP.NET MVC应用程序的web.config中设置一些301永久性重定向。IIS7和301永久重定向使用web.config中的位置标记

最简单的方法是添加类似于下面的web.config文件中的一个标签:

<location path="TheMenu.aspx"> 
     <system.webServer> 
      <httpRedirect enabled="true" destination="menus/" httpResponseStatus="Permanent" /> 
     </system.webServer> 
    </location> 

当我去到现场,在http://domain.com/TheMenu.aspx它重定向我http://domain.com/menusxd而不是http://domain.com/menus

这会导致什么?

+0

重复:http://stackoverflow.com/questions/3197319/asp-net-mvc-how-to-重定向-A-非www到WWW-和反之亦然/ 18160522#18160522 – 2013-08-10 09:26:44

回答

6

抱歉,我不能帮你<httpRedirect>,但你试过/你可以使用IIS7 URL Rewrite模块?

你的规则看起来是这样的:

<system.webServer> 
    <rewrite> 
     <rules> 
      <rule name="TheMenu" patternSyntax="Wildcard" stopProcessing="true"> 
       <match url="TheMenu.aspx" /> 
       <action type="Redirect" url="menus/" /> 
      </rule> 
     </rules> 
    </rewrite> 
</system.webServer> 

HTHS,
查尔斯