[英]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.