西数超哥博客
运维经验教程分享

httpd.ini伪静态规则转换为ii7规则后无法使用解决方法

在处理问题过程中,经常会遇到将http.ini规则转换为iis7规则,iis中导入规则后能正常转换为iis7规则,但实际上规则是有误的,无法正常使用,需参考如下方法修改后方可使用

url="/ 替换为  url="
.     替换为  . 
?     替换为  ?
_     替换为  _

//将http.ini规则直接在iis7下转换后的格式如下

<?xml version=”1.0″ encoding=”UTF-8″?>

<configuration>

    <system.webServer>

        <rewrite>

            <rules>

                <rule name=”Òѵ¼ÈëµÄ¹æÔò 1″ stopProcessing=”true”>

                    <match url=”^(.*)/article-([0-9]+).html$” />

                    <action type=”Rewrite” url=”{R:1}/article.asp?id={R:2}” appendQueryString=”false” />

                </rule>

                <rule name=”Òѵ¼ÈëµÄ¹æÔò 2″ stopProcessing=”true”>

                    <match url=”^(.*)/show-([0-9]+).html$” />

                    <action type=”Rewrite” url=”{R:1}/show.asp?id={R:2}” appendQueryString=”false” />

                </rule>

                <rule name=”Òѵ¼ÈëµÄ¹æÔò 3″ stopProcessing=”true”>

                    <match url=”^(.*)/guestbook.html$” />

                    <action type=”Rewrite” url=”{R:1}/guestbook.asp” />

                </rule>

            </rules>

        </rewrite>

    </system.webServer>

</configuration>

//重新调整后正确可用的规则如下 //去掉了“(.*)”、去掉了“{R:1}”、将{R:2}改成{R:1}、将多余的斜杠去掉了

<rule name=”Òѵ¼ÈëµÄ¹æÔò 1″ stopProcessing=”true”>

    <match url=”^article-([0-9]+).html$” />

    <action type=”Rewrite” url=”article.asp?id={R:1}” appendQueryString=”false” />

</rule>

<rule name=”Òѵ¼ÈëµÄ¹æÔò 2″ stopProcessing=”true”>

    <match url=”^show-([0-9]+).html$” />

    <action type=”Rewrite” url=”show.asp?id={R:1}” appendQueryString=”false” />

</rule>

<rule name=”Òѵ¼ÈëµÄ¹æÔò 3″ stopProcessing=”true”>

    <match url=”^guestbook.html$” />

    <action type=”Rewrite” url=”guestbook.asp” />

</rule>

赞(0)
声明:本站发布的内容(图片、视频和文字)以原创、转载和分享网络内容为主,若涉及侵权请及时告知,将会在第一时间删除。本站原创内容未经允许不得转载:西数超哥博客 » httpd.ini伪静态规则转换为ii7规则后无法使用解决方法

登录

找回密码

注册