IIS version: IIS 7.5
URL Rewrite component: IIS URL Rewrite module (http://www.iis.net/downloads/microsoft/url-rewrite)
As needed, click on the download link on the right (the operating system is 64-bit, download the x64 version, 32-bit system, download the x86 version)
Note that the currently installed version is in English.
After the download is complete, install the rewrite module.
Download the local MSI package (Rewrite_amd64.msi or Rewrite_x86.msi), double-click the installation (you should stop the IIS service before you install it, and if the IIS service does not stop, you will need to reboot the system after the installation is complete.) )
When the installation is complete, open Internet Information Services (IIS) Manager, and you will see a more than one URL Rewrite module in the module.
Enter the site you want to set up, double-click the Url Rewrite icon to enter the settings interface.
Click Add rule (s) to enter rewrite rewrite rules.
After confirmation, click the "Apply" button on the right column, and you are done
Of course, you can also import from a previously configured pseudo static file: Httpd.ini or. htaccess that support ISAPI
Case:
Very friendly URL address that makes it easy for people to remember. It's not wonderful to ask your users to remember URLs like "Http://www.jb51.net/article.aspx?id=342&;title=URL-Rewrite-Walkthrough". If you provide users with the following URL address: Http://www.pipima.com/article/342/URL-Rewrite-Walkthrough, it will be better to resonate and more easily remembered.
Through the IIS URL Rewrite module (URL Rewrite module) you can easily establish this logic without having to modify the Rewrite maps code you are using. I will tell you to implement it from IIS Manager. Open IIS Manager, select Default Web Site, click URL Rewrite in the function view, and then in the Action Bar, click Add Rules ... to select Blank in the Select a Rule Templates dialog box Rule, you will open the Edit Rules property page and define the actual overrides (rewrite) by following these steps:
1, the rule name.
2, the pattern used to match the URL string.
3, set the condition option.
4, pattern matching and all conditions check after the success of the operation.
To implement the following example, the Edit Rule property page is shown in the following illustration:
The name of the rule should be unique (not repeated), and the matching string "^article/([0-9]+)/([_0-9a-z-]+)" is a regular expression that matches any URL string that satisfies the criteria:
1, starting with the "article/" character sequence.
2, after "/" contains one or more numeric characters.
3, after the second "/" contains one or more letters or "_" or "-".
Because we create a rule that supports overriding URLs, the rule type is "Rewrite." The rewrite string (Rewrite UR) "Article.aspx?id={r:1}&title={r:2}" specifies a new value for entering the overridden URL. Parameters we use "{r:1}" and "{r:2}", they will return a set of references (reference) defined by rule matching. About return references (back reference) you can refer to: URL Rewrite Module Configuration reference, for more on creating rewrite rules see: Creating Rewrite Rules for the URL Rewrite Module
One important thing is that the URL rewrite module needs to be installed before it can work, and you can do the following two versions:
x86 version: http://www.iis.net/downloads/default.aspx?tabid=34&;g=6&i=1691
x64 version: http://www.iis.net/downloads/default.aspx?tabid=34&;g=6&i=1692
The module (currently) supports only IIS7.0 and you should run IIS7.0 to benefit from it. If your project is developed using visual Studio for WEB developers, the project should be configured to run under iis7.0 instead of other Web servers.
For a detailed description of the URL rewrite module, see: http://learn.iis.net/page.aspx/460/using-url-rewrite-module/
Attention:
1. The original conversion of {r:1}, the other syntax little change <rewrite url= "~/test/([a-za-z0-9_\-]+)/(\d+). html\? {0,1} (. *) $ "to=" ~/test.aspx?id=$4&$5 "processing=" Stop "/>
Into
<rule name= "Orgpage" stopprocessing= "true" >
<match url= "^test/" ([a-za-z0-9_\-]+)/(\d+). html\? {0,1} (. *) $ "/>
<action type= "Rewrite" Url= "Test.aspx?id={r:1}&{r:2}"/>
</rule>
2.UrlRewriter url= "~/module/" in the URL Rewrite module must be replaced by ^module/, or even if test passed, in the actual environment can not be resolved;
3. Previous Urlrewriter url= "^/([a-za-z0-9_]+)" is OK, but not in URL Rewrite module, you must add parameters
<conditions logicalgrouping= "Matchall" >
<add input= "{http_host}" pattern= "^blog\.lehu\.shu\.edu\.cn$"/>
<add input= "{request_filename}" matchtype= "Isfile" negate= "true"/>
<add input= "{request_filename}" matchtype= "Isdirectory" negate= "true"/>
</conditions>
4. In addition, you need to pay attention to the IIS6 config conversion to IIS7, you need to delete the applicationhost.config In general, IIS7 is more stable than IIS6, and in the present position, the buffer pool that always appears in IIS6 is rarely seen in IIS7. The specific situation also needs to be tested.
Rule Definition screenshot:
The rule definition in Web.config:
Copy Code code as follows:
<rewrite>
<rules>
<rule name= "RequestBlockingRule1" enabled= "true" stopprocessing= "true" >
<match url= ". *"/>
<conditions>
<add input= "{http_referer}" pattern= "^$" negate= "true"/>
<add input= ' {http_referer} ' pattern= ' ^http://(. *\.)? (cnblogs\.com)/.*$ "negate= true"/>
</conditions>
<action type= "Customresponse" statuscode= "404"/>
</rule>
</rules>
</rewrite>