您好,我正在尝试将我的域别名重定向到一个域。
我目前有这条规则
<rule name="WWW Rewrite" enabled="true">
<match url="(.*)" />
<conditions>
<add input="{HTTP_HOST}" negate="true"
pattern="^www\.([.a-zA-Z0-9]+)$" />
</conditions>
<action type="Redirect" url="http://www.domain.com/{R:0}"
appendQueryString="true" redirectType="Permanent" />
</rule>
当别名前面没有 www 时,它可以完美工作。我怎么说重定向所有不等于该域的内容
谢谢
最佳答案
尝试一下。我不确定它是否有效,我在这个主题上不太擅长,但这个问题已经在这里坐了 4 个月了,没有得到答复,所以我想我应该好好考虑一下。
<rule name="Rewrite domain requests" stopProcessing="true">
<match url="(.*)" />
<conditions>
<add input="{HTTP_HOST}" pattern="^(www.)?([.a-zA-Z0-9]+)$" />
</conditions>
<action type="Rewrite" url="http://www.mydomain.com/url={R:1}" appendQueryString="true" />
</rule>
这是我不确定的模式。我认为这表示,匹配 URL 中的任何内容,无论是否带 www,以及任何可能的域名扩展。
关于web-config - web.config 将多个域重定向到一个域,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9595529/