2014-02-14 80 views
3

使用標準iis url重寫模塊技術將http重定向到https不適用於iisnode。Url在http iisnode中將http重寫爲https

我有以下規則配置HTTP重定向到https:

<rule name="HTTP to Prod HTTPS redirect" stopProcessing="true"> 
    <match url="(.*)" /> 
    <conditions> 
    <add input="{HTTPS}" pattern="off" ignoreCase="true" /> 
    </conditions> 
    <action type="Redirect" redirectType="Found" url="https://{HTTP_HOST}/{R:1}" /> 
</rule> 

的問題是,請求 http://domain.net被重定向到https://domain.net/server.js

任何想法如何擺脫「服務器.js「部分的網址?

回答

4

好的,解決方案很簡單。我只需要在頂部放置HTTP - > HTTPS url重寫規則。最終配置可以如下所示:

<rewrite> 
    <rules> 
    <rule name="HTTP to Prod HTTPS redirect" stopProcessing="true"> 
     <match url="(.*)" /> 
     <conditions> 
     <add input="{HTTPS}" pattern="off" ignoreCase="true" /> 
     </conditions> 
     <action type="Redirect" redirectType="Found" url="https://{HTTP_HOST}/{R:1}" /> 
    </rule> 
    <!-- Don't interfere with requests for logs --> 
    <rule name="LogFile" patternSyntax="ECMAScript" stopProcessing="true"> 
     <match url="^[a-zA-Z0-9_\-]+\.js\.logs\/\d+\.txt$" /> 
    </rule> 
    <!-- Don't interfere with requests for node-inspector debugging --> 
    <rule name="NodeInspector" patternSyntax="ECMAScript" stopProcessing="true"> 
     <match url="^server.js\/debug[\/]?" /> 
    </rule> 
    <!-- First we consider whether the incoming URL matches a physical file in the  /public folder --> 
    <rule name="StaticContent"> 
     <action type="Rewrite" url="public{REQUEST_URI}" /> 
    </rule> 
    <!-- All other URLs are mapped to the Node.js application entry point --> 
    <rule name="DynamicContent"> 
     <conditions> 
     <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="True" /> 
     </conditions> 
     <action type="Rewrite" url="server.js" /> 
    </rule> 
    </rules> 
</rewrite> 
相關問題