2017-02-04 16 views
0

我有一個網站,同時支持HTTP和HTTPS(憑有效證書),但unfortunally與一些外部服務的內部問題上,HTTPS的配置還沒有準備好生產中去。重定向到Azure中的Web應用服務訪問http

我想現在通過IIS(web.config文件)將每個https請求重定向到http。

我在官方文檔中發現,代碼重定向從http到https,但不是相反。所以,我想將它轉換,但IIS不實際重定向:

<rule name="Redirect to HTTP" stopProcessing="true"> 
    <match url="(.*)" /> 
    <conditions> 
     <add input="{HTTP}" pattern="^OFF$" /> 
    </conditions> 
    <action type="Redirect" url="http://{HTTP_HOST}/{R:1}" redirectType="Permanent" /> 
</rule> 

回答

4

Azure的應用服務網站支持IIS URL重寫模塊等什麼你正在嘗試做的應該工作。我認爲你唯一犯錯的是條件,你添加了Server Variable的條件叫做HTTP,但是沒有HTTP,只有HTTPS或者是ON或者OFFSee this for full list of IIS Server Variables。所以,只要翻轉和而不是檢查,如果HTTP是OFF(不存在,永遠不會爲真),檢查,如果HTTPS是ON

<rule name="Redirect to HTTP" stopProcessing="true"> 
    <match url="(.*)" /> 
    <conditions> 
    <add input="{HTTPS}" pattern="^ON$" /> 
    </conditions> 
    <action type="Redirect" url="http://{HTTP_HOST}/{R:0}" redirectType="Permanent" /> 
</rule> 
相關問題