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

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

httpd.ini伪静态规则直接使用iis7导入后的默认规则如下:

  1. //将http.ini规则直接在iis7下转换后的格式如下
  2. <?xml version=“1.0” encoding=“UTF-8”?>
  3. <configuration>
  4. <system.webServer>
  5. <rewrite>
  6. <rules>
  7. <rule name=“Òѵ¼ÈëµÄ¹æÔò 1” stopProcessing=“true”>
  8. <match url=“^(.*)/article-([0-9]+).html$” />
  9. <action type=“Rewrite” url=“{R:1}/article.asp?id={R:2}” appendQueryString=“false” />
  10. </rule>
  11. <rule name=“Òѵ¼ÈëµÄ¹æÔò 2” stopProcessing=“true”>
  12. <match url=“^(.*)/show-([0-9]+).html$” />
  13. <action type=“Rewrite” url=“{R:1}/show.asp?id={R:2}” appendQueryString=“false” />
  14. </rule>
  15. <rule name=“Òѵ¼ÈëµÄ¹æÔò 3” stopProcessing=“true”>
  16. <match url=“^(.*)/guestbook.html$” />
  17. <action type=“Rewrite” url=“{R:1}/guestbook.asp” />
  18. </rule>
  19. </rules>
  20. </rewrite>
  21. </system.webServer>
  22. </configuration>
  23. //重新调整后正确可用的规则如下
  24. //去掉了“(.*)”、去掉了“{R:1}”、将{R:2}改成{R:1}、将多余的斜杠去掉了
  25. <rule name=“Òѵ¼ÈëµÄ¹æÔò 1” stopProcessing=“true”>
  26. <match url=“^article-([0-9]+).html$” />
  27. <action type=“Rewrite” url=“article.asp?id={R:1}” appendQueryString=“false” />
  28. </rule>
  29. <rule name=“Òѵ¼ÈëµÄ¹æÔò 2” stopProcessing=“true”>
  30. <match url=“^show-([0-9]+).html$” />
  31. <action type=“Rewrite” url=“show.asp?id={R:1}” appendQueryString=“false” />
  32. </rule>
  33. <rule name=“Òѵ¼ÈëµÄ¹æÔò 3” stopProcessing=“true”>
  34. <match url=“^guestbook.html$” />
  35. <action type=“Rewrite” url=“guestbook.asp” />
  36. </rule>
//将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>

&nbsp;

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

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

微信扫一扫打赏