2010-03-30 31 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,
查爾斯