首页 > 技术交流 > iis7中Rewrite配置文件web.config伪静态设置使用说明
iis7中Rewrite配置文件web.config伪静态设置使用说明 2012-8-13

WIN IIS7.0 Rewrite 伪静态设置使用说明,首先在根目录建立web.config文件。这里提供个实例给大家参考,通过测试。

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.webServer>
        <rewrite>
            <rules>
                <rule name="Imported Rule 1">
                    <match url="^about-(\d+)/index.shtml$" ignoreCase="false" />
                    <action type="Rewrite" url="about.asp?class_id={R:1}" />
                </rule>
                <rule name="Imported Rule 2">
                    <match url="^equipment-(\d+)/index.shtml$" ignoreCase="false" />
                    <action type="Rewrite" url="equipment.asp?class_id={R:1}" />
                </rule>
                <rule name="Imported Rule 3">
                    <match url="^equipment-(\d+)/(\d+)/" ignoreCase="false" />
                    <action type="Rewrite" url="equipment-view.asp?class_id={R:1}&amp;nid={R:2}"  />
                </rule>
                <rule name="Imported Rule 4">
                    <match url="^quality-(\d+)/index.shtml$" ignoreCase="false" />
                    <action type="Rewrite" url="quality.asp?class_id={R:1}" />
                </rule>
                <rule name="Imported Rule 5">
                    <match url="^quality-(\d+)/(\d+)/$" ignoreCase="false" />
                    <action type="Rewrite" url="quality-view.asp?class_id={R:1}&amp;nid={R:2}" />
                </rule>
                <rule name="Imported Rule 6">
                    <match url="^news-(\d+)/index.shtml$" ignoreCase="false" />
                    <action type="Rewrite" url="news.asp?class_id={R:1}"  />
                </rule>
                <rule name="Imported Rule 7">
                    <match url="^contact-(\d+)/index.shtml$" ignoreCase="false" />
                    <action type="Rewrite" url="contact.asp?class_id={R:1}"  />
                </rule>
                <rule name="Imported Rule 8">
                    <match url="^([a-zA-Z0-9-_]+)-(\d+)/$" ignoreCase="false"    />
                    <action type="Rewrite" url="index.asp?flod={R:1}&amp;class_id={R:2}" />
                </rule>
                <rule name="Imported Rule 9">
                    <match url="^products/index(\d+).shtml$" ignoreCase="false" />
                    <action type="Rewrite" url="products.asp?class_id={R:1}"  />
                </rule>
                <rule name="Imported Rule 10">
                    <match url="^products/index(\d+)_page(\d+)/$" ignoreCase="false" />
                    <action type="Rewrite" url="products.asp?class_id={R:1}&amp;page={R:2}"  />
                </rule>
                <rule name="Imported Rule 11">
                    <match url="^products/([a-zA-Z0-9-_]+)-(\d+)/$" ignoreCase="false" />
                    <action type="Rewrite" url="productslist.asp?flod={R:1}&amp;class_id={R:2}"  />
                </rule>
                <rule name="Imported Rule 12">
                    <match url="^products/([a-zA-Z0-9-_]+)-(\d+)_page(\d+)/$" ignoreCase="false" />
                    <action type="Rewrite" url="productslist.asp?flod={R:1}&amp;class_id={R:2}&amp;page={R:3}"  />
                </rule>
                <rule name="Imported Rule 13">
                    <match url="^products/(\d+).shtml$" ignoreCase="false" />
                    <action type="Rewrite" url="show-products.asp?pid={R:1}"  />
                </rule>
                <rule name="Imported Rule 14">
                    <match url="^(.*).shtml$" ignoreCase="false" />
                    <action type="Rewrite" url="{R:1}.asp" appendQueryString="false" />
                </rule>
              
            </rules>
        </rewrite>
    </system.webServer>
</configuration>

 

:ignoreCase区分大小写

规则一定要写正确,多个传值时“&”在规则中是“&amp;”; 

上一篇:在网页上增加新浪微博关注按钮 下一篇:npmaker 一直在读取解决方法