IIS7偽靜態(tài)web.config配置的方法和規(guī)則
來源:易賢網(wǎng) 閱讀:841 次 日期:2016-08-09 15:27:01
溫馨提示:易賢網(wǎng)小編為您整理了“IIS7偽靜態(tài)web.config配置的方法和規(guī)則”,方便廣大網(wǎng)友查閱!

以前在IIS6上配置偽靜態(tài)還是挺復(fù)雜的,IIS7之后使用了插件機(jī)制,這讓我們做偽靜態(tài)變得簡(jiǎn)單多了。

一、服務(wù)器需要安裝:URL Rewrite 擴(kuò)展

下載地址:http://www.iis.net/download/URLRewrite

提示:雖然IIS7也可以使用以前在IIS6上那種老的方法來配置偽靜態(tài),但是我們不使用,因?yàn)槟菢拥脑捑腕w現(xiàn)不出IIS7的優(yōu)勢(shì)了。

二、在 web.config 中配置偽靜態(tài)規(guī)則

注意要點(diǎn)

1.參數(shù)用“()” 括起來 ,使用 {R:1}來獲得參數(shù)

2.多個(gè)參數(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="http://www.jb51.net/{R:0}" redirectType="Permanent" />

                </rule>

                <!--首頁(yè)-->

                <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)品列表第幾頁(yè)-->

                <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)品類別列表第幾頁(yè)-->

                <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)品詳細(xì)-->

                <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>

更多信息請(qǐng)查看網(wǎng)絡(luò)編程
易賢網(wǎng)手機(jī)網(wǎng)站地址:IIS7偽靜態(tài)web.config配置的方法和規(guī)則
由于各方面情況的不斷調(diào)整與變化,易賢網(wǎng)提供的所有考試信息和咨詢回復(fù)僅供參考,敬請(qǐng)考生以權(quán)威部門公布的正式信息和咨詢?yōu)闇?zhǔn)!
關(guān)于我們 | 聯(lián)系我們 | 人才招聘 | 網(wǎng)站聲明 | 網(wǎng)站幫助 | 非正式的簡(jiǎn)要咨詢 | 簡(jiǎn)要咨詢須知 | 加入群交流 | 手機(jī)站點(diǎn) | 投訴建議
工業(yè)和信息化部備案號(hào):滇ICP備2023014141號(hào)-1 云南省教育廳備案號(hào):云教ICP備0901021 滇公網(wǎng)安備53010202001879號(hào) 人力資源服務(wù)許可證:(云)人服證字(2023)第0102001523號(hào)
云南網(wǎng)警備案專用圖標(biāo)
聯(lián)系電話:0871-65317125(9:00—18:00) 獲取招聘考試信息及咨詢關(guān)注公眾號(hào):hfpxwx
咨詢QQ:526150442(9:00—18:00)版權(quán)所有:易賢網(wǎng)
云南網(wǎng)警報(bào)警專用圖標(biāo)