[英]IIS 8.5 Url Rewrite Issue - Redirect Location Includes IP Address
我創建了一個URL重寫規則,以基於http://madskristensen.net/post/url-rewrite-and-the-www-subdomain從傳入請求中刪除WWW
這是直接來自我的web.config的規則:
<rewrite>
<rules>
<rule name="Remove WWW" patternSyntax="Wildcard" stopProcessing="true">
<match url="*" />
<conditions>
<add input="{CACHE_URL}" pattern="*://www.*" />
</conditions>
<action type="Redirect" url="{C:1}://{C:2}" redirectType="Permanent" />
</rule>
</rules>
</rewrite>
當我嘗試打開www.mydomain.com時,FireFox給我一個“內容損壞錯誤”消息。 如果我嘗試在Chrome中打開它,則什么也不會發生。
這是通過Fiddler的響應頭:
HTTP/1.1 301 Moved Permanently
Content-Type: text/html; charset=UTF-8
Location: http://example.com:80:123.123.123.123/
Server: Microsoft-IIS/8.5
X-Powered-By: ASP.NET
Date: Mon, 07 Dec 2015 18:20:53 GMT
Content-Length: 167
響應主體:
<head>
<title>Document Moved</title>
</head>
<body>
<h1>Object Moved</h1>This document may be found <a HREF="http://example.com:80:123.123.123.123/">here</a>
</body>
注意端口和IP地址如何包含在位置中。 (我用123.123.123.123替換了服務器的IP地址)
這是問題所在嗎? 如果是這樣,為什么它包含此信息以及如何刪除它?
安裝URL重寫后,我重新啟動了IIS。
並不是真正的解決方案,但是我的解決方法...
我的網站設置為需要SSL,因此我並不需要從兩種協議中刪除WWW的好處。
我已將規則更新如下:
<rule name="Remove WWW and Redirect to HTTPS" enabled="true" stopProcessing="true">
<match url="(.*)" />
<conditions>
<add input="{HTTP_HOST}" pattern="^(www\.)(.*)$" />
</conditions>
<action type="Redirect" url="https://{C:2}/{R:1}" />
</rule>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.