Configure web. config in iis7 to implement pseudo-static

Source: Internet
Author: User

 

A few days ago, I changed the website space and found that the original URL rewriting was no longer valid. The original use was the pseudo-static implemented by urlRewriter, for URL rewriting in IIS6, you can refer to using URLRewriter. dll to implement url redirection. Through communication with customer service, we realized that in IIS7, we no longer need to install other components. By simply configuring web. config, we can implement pseudo-static URLs. The method is as follows:

 

Add the following code to the configuration node of the web. config configuration file:

 

<System. webServer>

<Rewrite>

<Rules>

<Rule name = "rulename">

<Match url = "newurl" ignoreCase = "false"/>

<Action type = "Rewrite" url = "oriurl" appendQueryString = "false"/>

</Rule>

</Rules>

</Rewrite>

</System. webServer>

Here are the URL rewriting rules for this site, which are clear to everyone: the rule node is each rewrite rule, the match node is a pseudo-static rule, and the ignoreCase is case-insensitive; action is the response URL, that is, the real URL; appendQueryString is the parameter or not. When adding multiple rule, note that the name should be different.

 

<Rewrite>

<Rules>

<Rule name = "rule1">

<Match url = "articles/(\ S +) \. html" ignoreCase = "true"/>

<Action type = "Rewrite" url = "articles/Default. aspx? SubClass = {R: 1} "appendQueryString =" true "/>

</Rule>

</Rules>

</Rewrite>

It can be seen that in IIS6, if the parameter is followed, $ is used, and {R: Number} is used in IIS7 instead of $. Do not forget to use & amp; replace & symbol for multiple parameters

 

 

From Tang ye's technical Garden

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.