將 https://mysite.com/Home/About 重導向至 https://www.mysite.com/home/about。Rewrite Module 處理重導向,Routing 處理 Controller 對應。
<rule name="Enforce canonical hostname" stopProcessing="true">
<match url="(.*)" />
<conditions><add input="{HTTP_HOST}" negate="true" pattern="^www\.mysite\.com$" /></conditions>
<action type="Redirect" url="https://www.mysite.com/{R:1}" redirectType="Permanent" />
</rule>
圖片請求 ^.+\.(jpg|bmp|gif)$ 透過 Rewrite 轉至 https://static_file_server/{R:0},動態頁面由 Routing 處理。
<rule name="Forward to static file server">
<match url="^.+\.(?:jpg|bmp|gif)$" />
<action type="Rewrite" url="https://static_file_server/{R:0}" />
</rule>