web.conf配置文件的格式
<?xml version="1.0" encoding="UTF-8"?> <configuration> <system.webServer> <rewrite> <rules> <rule name="Imported Rule 1"> <match url="ShowProduct/([0-9]*).html"/> <action type="Rewrite" url="/view.asp?id={R:1}" /> </rule> <rule name="Imported Rule 2"> <match url="about_([0-9]*).html"/> <action type="Rewrite" url="/about.asp?id={R:1}" /> </rule> </rules> </rewrite> </system.webServer> </configuration>
配置web.config文件由其它規(guī)則導(dǎo)入時(shí)要調(diào)整的地方:
1、match語(yǔ)句最前面不需要加“/”如:
<match url="/ShowProduct/([0-9]*).html"/>
修改為:
<match url="ShowProduct/([0-9]*).html"/>
(注:去掉了最前面“/”)
2、action語(yǔ)句內(nèi)不要使用轉(zhuǎn)義符號(hào)。如:
<action type="Rewrite" url="/view\.asp\?id={R:1}" />
修改為:
<action type="Rewrite" url="/view.asp?id={R:1}" />
(注:去掉了“.”與“?”的轉(zhuǎn)義符號(hào))