2015-12-07 39 views
1

我創建一個URL重寫規則刪除傳入的請求基於http://madskristensen.net/post/url-rewrite-and-the-www-subdomainIIS 8.5 URL重寫問題 - 從我的web.config重定向位置包括IP地址

這裏WWW是規則直:

<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中打開它,則什麼都不會發生。

通過提琴手這裏是響應頭:

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。

+0

我也面臨這個問題。任何解決方案 –

回答

0

不是一個真正的解決辦法,但我的解決辦法...

我的網站設置爲需要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>