simplify

【正义网络工作室】承接阿勒泰地区网站开发建设,全景拍摄,触摸屏网站制作,婚礼全景拍摄等业务。热爱生活,合格的吃货,单板滑雪狂热爱好者,吉他轮滑略知一二的淡定靠谱好青年。---http://simplify-deepin.blogbus.com (博客旧址)

©simplify
Powered by LOFTER

iis7中Rewrite配置文件web.config伪静态设置使用说明

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


以下是根据上述教程内容自己编写的规则,适用于本人开发的网站:

<system.webServer>

        <httpErrors errorMode="Custom">

            <remove statusCode="404" subStatusCode="-1" />

            <error statusCode="404" prefixLanguageFilePath="" path="/404.asp" responseMode="ExecuteURL" />

        </httpErrors>

         <rewrite>

            <rules>

                <rule name="Imported Rule 1">

                    <match url="^index.html$" ignoreCase="false" />

                    <action type="Rewrite" url="index.asp" />

                </rule>

                <rule name="Imported Rule 2">

                    <match url="^404.html$" ignoreCase="false" />

                    <action type="Rewrite" url="404.asp" />

                </rule>

                <rule name="Imported Rule 3">

                    <match url="^searchresult.html$" ignoreCase="false" />

                    <action type="Rewrite" url="searchresult.asp" />

                </rule>

                <rule name="Imported Rule 4">

                    <match url="^view-(\d+).html$" ignoreCase="false" />

                    <action type="Rewrite" url="view.asp?id={R:1}" />

                </rule>

                <rule name="Imported Rule 5">

                    <match url="^view_list-(\d+).html$" ignoreCase="false" />

                    <action type="Rewrite" url="view_list.asp?cataid={R:1}" />

                </rule>

                <rule name="Imported Rule 6">

                    <match url="^view_about-(\d+).html$" ignoreCase="false" />

                    <action type="Rewrite" url="view_about.asp?id={R:1}" />

                </rule>

                <rule name="Imported Rule 7">

                    <match url="^view_zt_list-(\d+).html$" ignoreCase="false" />

                    <action type="Rewrite" url="view_zt_list.asp?cataid={R:1}" />

                </rule>

                <rule name="Imported Rule 8">

                    <match url="^view_zt_about-(\d+).html$" ignoreCase="false" />

                    <action type="Rewrite" url="view_zt_about.asp?id={R:1}" />

                </rule>

                <rule name="Imported Rule 9">

                    <match url="^index_about-(\d+).html$" ignoreCase="false" />

                    <action type="Rewrite" url="index_about.asp?cataid={R:1}" />

                </rule>

                <rule name="Imported Rule 10">

                    <match url="^default_sc-(\d+).html$" ignoreCase="false" />

                    <action type="Rewrite" url="default_sc.asp?cataid={R:1}" />

                </rule>

                <rule name="Imported Rule 11">

                    <match url="^zt(\d+)-(\d+).html$" ignoreCase="false" />

                    <action type="Rewrite" url="zt{R:1}.asp?cataid={R:2}" />

                </rule>

                <rule name="Imported Rule 12">

                    <match url="^admin/login.html$" ignoreCase="false" />

                    <action type="Rewrite" url="admin/login.asp" />

                </rule>

            </rules>

        </rewrite>

    </system.webServer>

如果使用helicon的isapi则写法如下:

# Helicon ISAPI_Rewrite configuration file

# Version 3.1.0.104


RewriteRule /index.html /index.asp

RewriteRule /404.html /404.asp

RewriteRule /searchresult.html /searchresult.asp

RewriteRule /view-([0-9,a-z]*).html /view.asp\?id=$1

RewriteRule /view_list-([0-9,a-z]*).html /view_list.asp\?cataid=$1

RewriteRule /view_about-([0-9,a-z]*).html /view_about.asp\?id=$1

RewriteRule /view_zt_list-([0-9,a-z]*).html /view_zt_list.asp\?cataid=$1

RewriteRule /view_zt_about-([0-9,a-z]*).html /view_zt_about.asp\?id=$1

RewriteRule /index_about-([0-9,a-z]*).html /index_about.asp\?cataid=$1

RewriteRule /default_sc-([0-9,a-z]*).html /default_sc.asp\?cataid=$1

RewriteRule /zt([0-9,a-z]*)-([0-9,a-z]*).html /zt$1.asp\?cataid=$2


RewriteRule /qa-([0-9,a-z]*).html /qa.asp\?id=$1

RewriteRule /qa_list-([0-9,a-z]*).html /qa_list.asp\?cataid=$1

RewriteRule /qa_about-([0-9,a-z]*).html /qa_about.asp\?cataid=$1


RewriteRule /default_sc.html /default_sc.asp

RewriteRule /view_zt_list.html /view_zt_list.asp

RewriteRule /view_list.html /view_list.asp

RewriteRule /qa_about.html /qa_about.asp

RewriteRule /qa_list.html /qa_list.asp

RewriteRule /admin/login.html /admin/login.asp



内容来自:http://www.kaiwo123.com/jishu/show_182/

评论