When we perform SEO Optimization on websites, we often change websites without www to those with www. For example, we can redirect the user-entered baidu.com to www.baidu.com for 301.
No matter what method you are using, I use it anyway: Add the following configuration in the section of web. config:
<Rewrite>
<Rules>
<Rule name = "CanonicalHostName" stopProcessing = "true">
<Match url = "(. *)"/>
<Conditions>
<Add input = "{HTTP_HOST}" pattern = "^ baidu \. com $"/>
</Conditions>
<Action type = "Redirect" url = "http://www.baidu.com/?r}" redirectType = "Permanent"/>
</Rule>
</Rules>
</Rewrite>
In this way, the problem is easily solved.
However, today I encountered a small accident, that is, the names of rule on the same server cannot be repeated. That is to say, there are many websites on one server, and of course there will be many web pages. in the configuration, the redirected rule name attribute cannot be repeated; otherwise, an error is returned.
In short, the problem should be calm. Use exclusion to Solve the Problem slowly (I personally prefer to use this) until it no longer hurts.