IIS中使用URL重寫工具進(jìn)行rewrite的規(guī)則示例
web.config中system.webServer節(jié)點添加重寫規(guī)則
<rewrite>
<rules>
重寫規(guī)則
</rules>
</rewrite>
HTTP 重定向到 HTTPS
<rule name="HTTP to HTTPS redirect" stopProcessing="true">
<match url="(.*)" />
<conditions>
<add input="{HTTPS}" pattern="off" ignoreCase="true" />
</conditions>
<action type="Redirect" redirectType="Found" url="https://{HTTP_HOST}/{R:1}" />
</rule>
重定向到帶www的域名
<rule name="www redirect" stopProcessing="true">
<match url=".*" />
<conditions>
<add input="{HTTP_HOST}" pattern="^baidu.com$" />
</conditions>
<action type="Redirect" url="http://www.baidu.com/{R:0}" redirectType="Permanent" />
</rule>
多個域名重定向
<rule name="WWW Redirect" stopProcessing="true">
<match url=".*" />
<conditions>
<add input="{HTTP_HOST}" pattern="^baidu.com|idc.baidu.com$" />
</conditions>
<action type="Redirect" url="http://www.baidu.com/{R:0}" redirectType="Permanent" />
</rule>
強制使用小寫url
<rule name="LowerCase" stopProcessing="true">
<match url="[A-Z]" ignoreCase="false" />
<action type="Redirect" url="{ToLower:{URL}}" />
</rule>
用戶友好的url重寫,如:index.aspx?t=show&id={id}重寫到show_{id}.aspx
<rule name="show">
<match url="show_(\d+)((.aspx||.html)*)" ignoreCase="false" />
<action type="Rewrite" url="index.aspx?t=show&id={R:1}" appendQueryString="false" />
</rule>
如果您的問題還未解決可以聯(lián)系站長付費協(xié)助。

有問題可以加入技術(shù)QQ群一起交流學(xué)習(xí)
本站vip會員 請加入無憂模板網(wǎng) VIP群(50604020) PS:加入時備注用戶名或昵稱
普通注冊會員或訪客 請加入無憂模板網(wǎng) 技術(shù)交流群(50604130)
客服微信號:15898888535
聲明:本站所有文章資源內(nèi)容,如無特殊說明或標(biāo)注,均為采集網(wǎng)絡(luò)資源。如若內(nèi)容侵犯了原著者的合法權(quán)益,可聯(lián)系站長刪除。