我们在something.example.com上有一个网站,我们希望它始终跳转到www.example.com
我们已经有了“添加” www的规则。当用户仅放置example.com时。
但是我们有一个出于其他原因的测试网址,我们希望实时站点始终重定向到www.example.com,无论其在域名之前使用什么前缀。
答案 0 :(得分:0)
只需在.*
或IIS URL重写模式字段中使用此正则表达式<match url="" />
有关其他信息:
所以
.*
表示零个或多个字符
答案 1 :(得分:0)
根据您的描述,建议您尝试使用{http_host}来匹配url重写规则中的域部分。
详细信息,您可以参考以下规则:
<rule name="rediect" stopProcessing="true">
<match url=".*" />
<conditions logicalGrouping="MatchAny">
<add input="{HTTP_HOST}" pattern="^(.*).example.com" />
<add input="{HTTP_HOST}" pattern="^example.com" />
</conditions>
<action type="Redirect" url="http://www.example.com/{R:0}" />
</rule>