0
我想在IIS中实现规范名称的url重定向,事情是我使用Azure,因此它需要在web.config中完成。Azure网站的URL重定向
有2个域名www。 示例 .com和www。 example1 .com,还有一个博客www.example1.com/ 博客所有上述网址与我们没有www需要重定向到www。 example1 .com并保留任何文字.com后的博客等
我想实现以下,但要么不能解决URL或无限循环,我不太熟悉正则表达式,所以可以似乎并没有让所有的东西都起作用。
这里是我迄今为止
<rule name="Root Redirect" stopProcessing="true">
<match url=".*" negate="false" />
<action type="Redirect" url="http://www.example1.com/{R:0}" />
<conditions trackAllCaptures="true">
<add input="{HTTP_HOST}" pattern="^www\.example.com$" />
</conditions>
</rule>
<rule name="www Redirect" patternSyntax="Wildcard" stopProcessing="true">
<match url=".*" negate="false" />
<action type="Redirect" url="http://www.example1.com/{R:1}" />
<conditions trackAllCaptures="true">
<add input="{HTTP_HOST}" pattern="http://example1.com" />
</conditions>
</rule>
上面的代码适用于所有的情况下,除了2(罚全中铬错误)和4(无重定向发生在所有)。希望这有助于以及在此先感谢:-)
谢谢@viperguynaz。我仍然使用上面的代码获得相同的结果。这里是正则表达式失败的情况,“http:// example.com”会抛出DNS_PROBE_FINISHED_NXDOMAIN,而“http:// example1.com”显示为“http:// example1.com”而不是“www .example1.com” “PS: - 有意在URL中添加空格以在帖子上完全显示网址 – user5785372
DNS_PROBE_FINISHED_NXDOMAIN已修复......这是一个问题和CNAME条目丢失的DNS级别。 – user5785372
在根重定向后移动WWW并将Roo重定向的stopProcessing更改为false,然后更新WWW以评估example1 – viperguynaz