本文介绍了Web.config重定向到www.example到example的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想重定向 www.example , example 或 https:// www。 example example 。如何使用web.config文件执行此操作?
I want to redirect www.example, example or www.example to example. How do I do this with a web.config file?
推荐答案安装URL重写模块(默认情况下不安装) )。 www.iis/downloads/microsoft/url-rewrite
Install the URL Rewrite module (it doesn't install by default). www.iis/downloads/microsoft/url-rewrite
完成后,您可以在system.webServer / rewrite / rules下的web.config中设置规则部分。添加此规则:
Once you have that, you can set up a rules section in your web.config under system.webServer/rewrite/rules. Add this rule:
<rule name="Redirect www to domain" stopProcessing="true"> <match url="(.*)" /> <conditions logicalGrouping="MatchAny" trackAllCaptures="false"> <add input="{HTTPS}" pattern="^OFF$" /> <add input="{HTTP_HOST}" pattern="^www.example" /> </conditions> <action type="Redirect" url="example/{R:1}" /> </rule>更多推荐
Web.config重定向到http://www.example.com到https://example.com
发布评论