web.conf配置文件的格式
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="Imported Rule 1" stopProcessing="true">
<match url="ShowProduct/([0-9]*).html" ignoreCase="false" />
<conditions logicalGrouping="MatchAll">
<add input="Host:" pattern="www\.chinafu\.com" ignoreCase="false" />
</conditions>
<action type="Rewrite" url="/view.asp?id={R:1}" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
配置web.config文件由其它规则导入时要调整的地方:
1、match语句最前面不需要加“/”如:
<match url="/ShowProduct/([0-9]*).html" ignoreCase="false" />
修改为:
<match url="ShowProduct/([0-9]*).html" ignoreCase="false" />(注:去掉了最前面“/”)
2、action语句内不要使用转义符号。如:
<action type="Rewrite" url="/view\.asp\?id={R:1}" />
修改为:
<action type="Rewrite" url="/view.asp?id={R:1}" />(注:去掉了“.”与“?”的转义符号)
3、XML里不能有直接用&的啊,要用转义字符&啊
下面是XML中的一些转义符
<
<
小于号
>
>
大于号
&
&
和
'
'
单引号
"
"
双引号
只有"<" 字符和"&"字符对于XML来说是严格禁止使用的。剩下的都是合法的,为了减少出错,使用实体是一个好习惯。