在处理问题过程中,经常会遇到将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>