IIS7 偽靜態 web.config 配置方法


<rule name="Redirect" stopProcessing="true">
<match url=".*" />
<conditions>
<add input="{HTTP_HOST}" pattern="^(w1.baidu.com|w2.taobao.com|xyw0001.my3w.com)$" />
</conditions>
<action type="Rewrite" url="down2/{R:0}" />
</rule>

 

df

IIS7 做偽靜態比較的簡單方便  

1.程序方面
只需要設置web.config 就可以了。
 

2.服務器需要安裝:URL Rewrite
下載地址:http://www.iis.net/download/URLRewrite
Godaddy 的主機已經安裝這個插件。
本地在測試的時候 請查看自己是否安裝這個插件。
 

 
注意要點
1.參數用“()” 括起來 ,使用 {R:1}來獲得參數
2.多個參數中間用 &amp; 分割
3.name切記不能寫一樣 
 

<?xml version="1.0"?>

<configuration>
<system.webServer>
        <rewrite>
            <rules>

<!--把二級域名(或指定的域名) 轉到目錄下-->

<rule name="Redirect" stopProcessing="true">
<match url=".*" />
<conditions>
<add input="{HTTP_HOST}" pattern="^(w1.baidu.com|w2.taobao.com|xyw0001.my3w.com)$" />
</conditions>
<action type="Rewrite" url="down2/{R:0}" />
</rule>


<!--301重定向把不帶3W的域名 定向到帶3W--> <rule name="Redirect" stopProcessing="true"> <match url=".*" /> <conditions> <add input="{HTTP_HOST}" pattern="^haoxinwen.info$" /> </conditions> <action type="Redirect" url="http://www.haoxinwen.info/{R:0}" redirectType="Permanent" /> </rule> <!--首頁--> <rule name="rD"> <match url="^$" /> <action type="Rewrite" url="Default.aspx" /> </rule> <!--產品列表--> <rule name="rP"> <match url="^product/$" /> <action type="Rewrite" url="ProductList.aspx" /> </rule> <!--產品列表第幾頁--> <rule name="rPL"> <match url="^product/list-([0-9]*).html$" /> <action type="Rewrite" url="ProductList.aspx?page={R:1}" /> </rule> <!--產品類別列表--> <rule name="rPT"> <match url="^product/([A-Za-z0-9-]*)/$" /> <action type="Rewrite" url="ProductList.aspx?typeUrl={R:1}" /> </rule> <!--產品類別列表第幾頁--> <rule name="rPTL2"> <match url="^product/([A-Za-z0-9-]*)/list-([0-9]*).html$" /> <action type="Rewrite" url="ProductList.aspx?typeUrl={R:1}&amp;page={R:2}" /> </rule> <!--產品詳細--> <rule name="rPd"> <match url="^product/([A-Za-z0-9-]*)/([A-Za-z0-9-]+).html$" /> <action type="Rewrite" url="ProductDetail.aspx?typeUrl={R:1}&amp;url={R:2}" /> </rule> </rules> </rewrite> </system.webServer> </configuration>

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM