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