以前在IIS6上配置偽靜態(tài)還是挺復雜的,IIS7之后使用了插件機制,這讓我們做偽靜態(tài)變得簡單多了。
一、服務器需要安裝:URL Rewrite 擴展
下載地址:http://www.iis.net/download/URLRewrite
提示:雖然IIS7也可以使用以前在IIS6上那種老的方法來配置偽靜態(tài),但是我們不使用,因為那樣的話就體現(xiàn)不出IIS7的優(yōu)勢了。
二、在 web.config 中配置偽靜態(tài)規(guī)則
注意要點
1.參數(shù)用“()” 括起來 ,使用 {R:1}來獲得參數(shù)
2.多個參數(shù)中間用 分割
3.name切記不能寫一樣
復制代碼 代碼如下:
?xml version="1.0"?>
configuration>
system.webServer>
rewrite>
rules>
!--301重定向把不帶3W的域名 定向到帶3W-->
rule name="Redirect" stopProcessing="true">
match url=".*" />
conditions>
add input="{HTTP_HOST}" pattern="^jb51.net$" />
/conditions>
action type="Redirect" url="https://www.jb51.net/{R:0}" redirectType="Permanent" />
/rule>
!--首頁-->
rule name="rD">
match url="^$" />
action type="Rewrite" url="Default.aspx" />
/rule>
!--產(chǎn)品列表-->
rule name="rP">
match url="^product/$" />
action type="Rewrite" url="ProductList.aspx" />
/rule>
!--產(chǎn)品列表第幾頁-->
rule name="rPL">
match url="^product/list-([0-9]*).html$" />
action type="Rewrite" url="ProductList.aspx?page={R:1}" />
/rule>
!--產(chǎn)品類別列表-->
rule name="rPT">
match url="^product/([A-Za-z0-9-]*)/$" />
action type="Rewrite" url="ProductList.aspx?typeUrl={R:1}" />
/rule>
!--產(chǎn)品類別列表第幾頁-->
rule name="rPTL2">
match url="^product/([A-Za-z0-9-]*)/list-([0-9]*).html$" />
action type="Rewrite" url="ProductList.aspx?typeUrl={R:1}page={R:2}" />
/rule>
!--產(chǎn)品詳細-->
rule name="rPd">
match url="^product/([A-Za-z0-9-]*)/([A-Za-z0-9-]+).html$" />
action type="Rewrite" url="ProductDetail.aspx?typeUrl={R:1}url={R:2}" />
/rule>
/rules>
/rewrite>
/system.webServer>
/configuration>
您可能感興趣的文章:- 比較詳細的win2003 IIS6.0 301重定向帶參數(shù)的問題解決方法
- IIS7/IIS7.5 二級域名偽靜態(tài)設置方法
- Win7/Windows2003下IIS6.0、IIS7.5的偽靜態(tài)組件安裝和偽靜態(tài)配置方法
- IIS7.5下301重定向的設置方法(及偽靜態(tài)后301重定向出錯案例)
- IIS7.5使用web.config設置偽靜態(tài)的二種方法
- windows IIS6服務器全站301永久重定向設置方法
- IIS7.5 偽靜態(tài) 腳本映射 配置方法(圖文詳解)
- Win2008 r2 iis7/iis7.5系統(tǒng)下HTTP重定向(301重定向)圖文方法