使用 IIS URL 重写将 IP 重定向到 CNAME
我有一个网站在 IP 地址 1.2.3.4 上运行,主机名为 www.host.com。 Web 服务器上仅运行一个网站,可以通过 http://1.2.3.4、http://www.host.com、< em>http://www.cname.com。我更喜欢用户通过 CNAME www.cname.com 访问它(映射到 www.host.com),因此我想重定向来自 的流量http://1.2.3.4 或 http://www.host.com 到 http://www.cname.com。是否可以通过 IIS URL Rewrite 来实现?
我尝试了以下规则,但不断收到重定向循环错误。
<rule name="RedirectToMitigatr" stopProcessing="true">
<match url="^((?!www.cname.com).)*$" />
<action type="Redirect" url="https://www.cname.com/{R:1}" />
</rule>
我认为规则应该做的是匹配任何不包含www.cname.com到https://www.cname.com。但显然不是 :p
谢谢!
I have a website running on IP address 1.2.3.4 with hostname www.host.com. The web server only have one website running on it, and it can be accessed by http://1.2.3.4, http://www.host.com, http://www.cname.com. I prefer users to access it by a CNAME www.cname.com (which maps to www.host.com), so I want to redirect traffic coming from http://1.2.3.4 or http://www.host.com to http://www.cname.com. Is it possible to achieve it with IIS URL Rewrite?
I tried the following rule but keeps getting redirect loop error.
<rule name="RedirectToMitigatr" stopProcessing="true">
<match url="^((?!www.cname.com).)*$" />
<action type="Redirect" url="https://www.cname.com/{R:1}" />
</rule>
What I think the rule should do is that it matches anything doesn't contain www.cname.com to https://www.cname.com. But apparently it's not :p
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您实际上无法将流量从一个 IP 地址重定向到另一个 IP 地址。
我做出以下假设:
1. 您希望您的网站位于 www.cname.com
2. host.com 应重定向到 www.cname.com
您收到错误,因为您实际上是将流量从 www.cname.com 重定向到 www.cname.com 。您需要将 url 匹配设置为 www.host.com
为此,首先您需要将 www.cname.com 指向与您的网站 host.com 相同的目录
假设您已正确映射名称服务器,请创建一个新的虚拟主机cname.com 并将其指向您想要网站的同一目录
访问 http://support.microsoft.com/kb/816576 了解更多信息
You cannot actually redirect traffic from an IP address to another.
I'm making the following assumptions:
1. you want your website on www.cname.com
2. host.com should redirect to www.cname.com
You are receiving an error since you are essentially redirecting traffic from www.cname.com to www.cname.com . You need to set url match to www.host.com
To do this,first you need to point www.cname.com to the same directory as your website host.com
Assuming you have mapped the name servers correctly, create a new virtual host for cname.com and point it to the SAME directory where you want your website
Visit http://support.microsoft.com/kb/816576 for more information