加幾句,1、安裝url重寫模塊,不需要重啟IIS,安裝完了就能用。個人感覺比 IIS REWRITE組件更好用,iis rewrite是安裝第三方的那種,不繳費只可以把所有規則寫在一起,不能區別站點,微軟自己這個可以區別站點,把規則寫在web.config
2、如果你已經安裝了並且有規則,直接拷貝下面代碼到 <rules></rules>節點中即可。
3、如果已經有其他規則,拷貝下面代碼的時候,要放在其他規則前面。不然會有一點小誤差。表現為假設你訪問 m.xxxx.com/1233 ,它會跳轉成了你rewrite之前的地址,比如轉為 https://m.xxxx.com/product/?id=1233 。所以得放在所有規則之前,並去掉 stopProcessing="true"
<rule name="redirec to https" stopProcessing="true">
<match url="(.*)" />
<conditions>
<add input="{HTTPS}" pattern="^OFF$" />
</conditions>
<action type="Redirect" url="https://{HTTP_HOST}/{R:1}" redirectType="Temporary" />
</rule>
====
記錄一下 以下是指定特定頁面不跳轉https
<rule name="redirec to https">
<match url="(.*)" />
<conditions>
<add input="{REQUEST_URI}" pattern="^/mapp/?$" negate="true" />
<add input="{REQUEST_URI}" pattern="^/mapp/mShop/?" negate="true" />
<add input="{HTTPS}" pattern="^OFF$" />
</conditions>
<action type="Redirect" url="https://{HTTP_HOST}/{R:1}" redirectType="Temporary" />
</rule>
======================以下配置過程,是轉來的
系統:Windows server 2008 R2
軟件:IIS7
配置方法:
1.安裝URL重寫模塊(默認是沒有安裝的)
32位的 http://download.microsoft.com/download/4/9/C/49CD28DB-4AA6-4A51-9437-AA001221F606/rewrite_x86_zh-CN.msi 64位 http://download.microsoft.com/download/4/E/7/4E7ECE9A-DF55-4F90-A354-B497072BDE0A/rewrite_x64_zh-CN.msi
- 1
- 2
- 3
- 4
2.服務器打開IIS,點擊左側對應的網站,然后在右面找到”URL重寫”項
2.添加規則(點擊右側添加規則,選中空白規則,然后確定)
3.給規則自定義一個名字(名稱自便),模式:(.*)
4.添加條件
5.配置操作
6.點擊右上角的應用
注意:
1.ssl設置取消”要求ssl”
2.當然你的網站要添加一條網站綁定
這樣配置就成功了