[英]IIS 7.5 URL Rewrite: Redirect Rule does not appear to work from old domain to new domain
我试图理解为什么当有人尝试进入站点时在IIS中创建的以下规则不起作用。
基本上,我们有一个旧域和一个新域。 我希望将所有转到旧域的人重定向到我们新域上的登录页面。
我正在该站点上使用ASP MVC4,并且已经为域添加了绑定并更新了DNS。
我的规则是:
<rule name="http://www.olddomain.com to landing page" patternSyntax="Wildcard" stopProcessing="true">
<match url="*" />
<action type="Redirect" url="http://www.new-domain.co.uk/LandingPage" />
<conditions logicalGrouping="MatchAny">
<add input="{HTTP_HOST}" pattern="http://www.olddomain.com" />
<add input="{HTTP_HOST}" pattern="http://olddomain.com" />
<add input="{HTTP_HOST}" pattern="http://www.olddomain.com/" />
<add input="{HTTP_HOST}" pattern="http://olddomain.com/" />
</conditions>
</rule>
目前,如果有人输入旧域地址,则重定向不会执行任何操作,该网站就像您通过新域进入首页一样,将被加载。
有人可以告诉我我要去哪里错吗?
更新下面提供的规则似乎仍然不起作用,因此我决定尝试在提琴手中打开我的旧域地址,看看是否可以看到重定向或响应。 我得到的只是一个200 HTTP响应,仅此而已。 这使我认为重写规则实际上被忽略了,但是我不知道为什么。
{HTTP_HOST}
将始终只是主机名,并且不包括协议或路径。 尝试将规则更改为此:
<rule name="http://www.olddomain.com to landing page" patternSyntax="Wildcard" stopProcessing="true">
<match url="*" />
<action type="Redirect" url="http://www.new-domain.co.uk/LandingPage" />
<conditions logicalGrouping="MatchAny">
<add input="{HTTP_HOST}" pattern="^www\.olddomain\.com$" />
<add input="{HTTP_HOST}" pattern="^olddomain\.com$" />
</conditions>
</rule>
我为此奋斗了几天。 我尝试的10-20重写规则和失败原因是:
Request 1 (from client): Get file.htm
Response 1 (from server): The file is moved, please request the file newFileName.htm
Request 2 (from client): Get newFileName.htm
Response 2 (from server): Here is the content of newFileName.htm
Request 1 (from client): Get file.htm
URL Rewriting (on server): Translate the URL file.htm to file.asp
Web application (on server): Process the request (run any code in file.asp)
Response 1 (from server): Here is the content of file.htm (note that the client does not know that this is the content of file.asp)
whether you need HttpRedirect or UrlRewrite
https://weblogs.asp.net/owscott/rewrite-vs-redirect-what-s-the-difference
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.