Asp.net mvc 4 IIS 7.5 URL重写:从旧域到新域的重定向规则似乎不起作用
我试图理解为什么当一个人试图进入网站时,IIS中创建的以下规则不起作用 基本上我们有一个旧域和一个新域。我想任何人去旧域被重定向到我们的新域上的登录页 我正在为该站点使用ASP MVC4,我已经为域添加了绑定,并更新了DNS 我的规则是:Asp.net mvc 4 IIS 7.5 URL重写:从旧域到新域的重定向规则似乎不起作用,asp.net-mvc-4,url,redirect,iis,url-rewrite-module,Asp.net Mvc 4,Url,Redirect,Iis,Url Rewrite Module,我试图理解为什么当一个人试图进入网站时,IIS中创建的以下规则不起作用 基本上我们有一个旧域和一个新域。我想任何人去旧域被重定向到我们的新域上的登录页 我正在为该站点使用ASP MVC4,我已经为域添加了绑定,并更新了DNS 我的规则是: <rule name="http://www.olddomain.com to landing page" patternSyntax="Wildcard" stopProcessing="true">
<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>
此时,如果有人输入旧域地址,重定向不会做任何事情,网站只会加载,就像您通过新域进入主页一样
有人能告诉我哪里出了问题吗
更新
下面提供的规则似乎仍然不起作用,所以我决定尝试在fiddler中打开我的olddomain地址,看看是否可以看到重定向或响应。我得到的只是一个200HTTP响应,仅此而已。这让我觉得重写规则实际上被忽略了,但我不知道为什么。
{HTTP\u HOST}
将始终只是主机名,而不包括协议或路径。尝试将规则更改为:
我为此挣扎了好几天。10-20重写规则我尝试过,失败原因如下:
谢谢你的回复。我刚刚注意到我用HTTP_POST打错了字!谢谢你发现了这一点。然而,这项新规则仍然没有如预期的那样发挥作用。所发生的一切就是站点在其默认页面上打开,而重定向不会发生occur@DavidHirst尝试将匹配URL更改为
。模式语法使用通配符。删除此属性并使用
这似乎对我仍然不起作用。请检查我上面的更新。
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