簡體   English   中英

IIS7網址重寫-從{any} .aspx重定向到{any}

[英]IIS7 Url Rewrite - Redirect from {any}.aspx to {any}

我正在將我的網站從Asp.Net Webforms轉換為Asp.Net MVC。 我想重定向所有舊的.aspx文件以刪除.aspx。 我在安裝了“ URL重寫”模塊的情況下運行IIS7。

例:

/about.aspx-> / about

用戶將轉到http://www.site.com/about.aspx ,我希望他們重定向到http://www.site.com/about

如何使用網址重寫執行此操作? 我不想對每個.aspx都進行處理,而不必在其中添加元重定向。

在system.webServer配置部分的web.config文件中,添加:

<rewrite>
  <rules>
    <rule name="WebFromsToMVC" stopProcessing="true">
      <match url="^(.*?)\.aspx\?*?.*$" />
        <conditions>
          <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
          <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
        </conditions>
      <action type="Rewrite" url="{R:1}" />
    </rule>
  </rules>
</rewrite>

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM