在iis7之后微软提供了url重写2.0版本,能够经过安装重写组件来实现。适用于iis7以上版本。html
安装有两种方式能够选择,一是下载安装文件,二是经过“web平台安装程序”安装web
一、下载安装文件dom
下载地址:https://www.microsoft.com/zh-cn/download/details.aspx?id=7435网站
或url
https://www.iis.net/downloads/microsoft/url-rewrite .net
二、“web平台安装程序”安装code
安装完成后iis的网站中会出现”url重写”图标: htm
Webconfig不用再和1.0时写不少的配置内容,只在system.webServer中写重写规则就能够了:blog
<system.webServer> <rewrite> <rules> <rule name="q" stopProcessing="true"> <match url="^a/(.*)\.html$" /> <action type="Rewrite" url="/a.aspx?domain={C:1}&id={R:1}" /> <conditions> <add input="{HTTP_HOST}" pattern="^(.*)\.morecoder\.com$" /> </conditions> </rule> </rules> </rewrite> </system.webServer>