IIS7伪静态Web.config地址重写实例,Web.config文件URL重写规则参考如下:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<!--伪静态规则IIS7-->
<system.webServer>
<rewrite>
<rules>
<rule name="product_aspx" stopProcessing="true">
<match url="^product(\d+).aspx" />
<action type="Rewrite" url="product.aspx?id={R:1}" />
</rule>
<rule name="catalog_aspx" stopProcessing="true">
<match url="^catalog(\d+).aspx" />
<action type="Rewrite" url="catalog.aspx?id={R:1}" />
</rule>
<rule name="hot0" stopProcessing="true">
<match url="^hot0-(\d+).aspx" />
<action type="Rewrite" url="hot.aspx?page={R:1}" />
</rule>
<rule name="hot01" stopProcessing="true">
<match url="^hot0-(\d+)-(\w+)-(\w+).aspx" />
<action type="Rewrite" url="hot.aspx?page={R:1}&orderby={R:2}&type={R:3}" />
</rule>
<rule name="news_pages" stopProcessing="true">
<match url="^news(\d+)-(\d+).aspx" />
<action type="Rewrite" url="news.aspx?id={R:1}&page={R:2}" />
</rule>
<rule name="productpl" stopProcessing="true">
<match url="^productpl(\d+)-(\d+).aspx" />
<action type="Rewrite" url="productpl.aspx?id={R:1}&page={R:2}" />
</rule>
<rule name="promotions0" stopProcessing="true">
<match url="^promotions0-(\d+).aspx" />
<action type="Rewrite" url="promotions.aspx?page={R:1}" />
</rule>
<rule name="promotions01" stopProcessing="true">
<match url="^promotions0-(\d+)-(\w+)-(\w+).aspx" />
<action type="Rewrite" url="promotions.aspx?page={R:1}&orderby={R:2}&type={R:3}" />
</rule>
<rule name="searched1" stopProcessing="true">
<match url="^searched-(\d+)-(\w+).aspx" />
<action type="Rewrite" url="searched.aspx?page={R:1}&key={R:2}" />
</rule>
<rule name="specials0" stopProcessing="true">
<match url="^specials0-(\d+).aspx" />
<action type="Rewrite" url="specials.aspx?page={R:1}" />
</rule>
<rule name="specials01" stopProcessing="true">
<match url="^specials0-(\d+)-(\w+)-(\w+).aspx" />
<action type="Rewrite" url="specials.aspx?page={R:1}&orderby={R:2}&type={R:3}" />
</rule>
</rule>
</rules>
</rewrite>
</system.webServer>
<!--伪静态规则结束IIS7-->
<appSettings>
<add key="ProductPageCount" value="36" />
</appSettings>
<system.web>
<customErrors mode="RemoteOnly" defaultRedirect="err.html" />
<globalization requestEncoding="utf-8" responseEncoding="utf-8" />
</system.web>
</configuration>
注意,以上地址重写规则只能在iis7+才有效。