1. 程式人生 > >IIS7偽靜態web.config配置的方法和規則

IIS7偽靜態web.config配置的方法和規則


< ?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>
                <!--首頁-->
                <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}&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}&url={R:2}" />
                </rule>
            </rules>
        </rewrite>
    </system.webServer>
< /configuration>