Methods and rules of IIS7 pseudo static web. config configuration
- 2021-07-18 07:49:21
- OfStack
Before, it was quite complicated to configure pseudo-static on IIS6. After IIS7, plug-in mechanism was used, which made it much easier for us to do pseudo-static.
1. Server needs to be installed: URL Rewrite extension
Download address: http://www.iis.net/download/URLRewrite
Tip: Although IIS7 can also use the old method used on IIS6 to configure pseudo-static, we don't use it because it doesn't show the advantages of IIS7.
2. Configure pseudo-static rules in web. config
Points for Attention
1. Parameters are enclosed with "()" and used {R: 1} to get the parameters
2. Use multiple parameters in between
&
Segmentation
3. name Remember not to write 1 sample
<?xml version="1.0"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<!--301 Redirect without 3W Domain name of Direction to belt 3W-->
<rule name="Redirect" stopProcessing="true">
<match url=".*" />
<conditions>
<add input="{HTTP_HOST}" pattern="^ofstack.com$" />
</conditions>
<action type="Redirect" url="https://www.ofstack.com/{R:0}" redirectType="Permanent" />
</rule>
<!-- Home page -->
<rule name="rD">
<match url="^$" />
<action type="Rewrite" url="Default.aspx" />
</rule>
<!-- Product list -->
<rule name="rP">
<match url="^product/$" />
<action type="Rewrite" url="ProductList.aspx" />
</rule>
<!-- What page is the product list -->
<rule name="rPL">
<match url="^product/list-([0-9]*).html$" />
<action type="Rewrite" url="ProductList.aspx?page={R:1}" />
</rule>
<!-- List of product categories -->
<rule name="rPT">
<match url="^product/([A-Za-z0-9-]*)/$" />
<action type="Rewrite" url="ProductList.aspx?typeUrl={R:1}" />
</rule>
<!-- What page is the product category list -->
<rule name="rPTL2">
<match url="^product/([A-Za-z0-9-]*)/list-([0-9]*).html$" />
<action type="Rewrite" url="ProductList.aspx?typeUrl={R:1}&page={R:2}" />
</rule>
<!-- Product details -->
<rule name="rPd">
<match url="^product/([A-Za-z0-9-]*)/([A-Za-z0-9-]+).html$" />
<action type="Rewrite" url="ProductDetail.aspx?typeUrl={R:1}&url={R:2}" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>