2017-04-12 56 views
1

我已經創建了ASP.NET Core項目,併爲我的網站購買了SSL。我在我的web.config中創建了一個重定向規則,將我的http重定向到https。我的問題是,我的網站上的每個鏈接現在都有https,這是由於某些鏈接沒有ssl導致證書問題。這是我所做的:IIS將http重定向到https僅適用於域

<rewrite> 
    <rules> 
    <rule name="Redirect to https"> 
     <match url="(.*)" /> 
     <conditions> 
     <add input="{HTTPS}" pattern="Off" /> 
     <add input="{REQUEST_METHOD}" pattern="^get$|^head$" /> 
     <add input="{HTTP_HOST}" negate="true" pattern="localhost" /> 
     </conditions> 
     <action type="Redirect" url="https://{HTTP_HOST}/{R:1}" /> 
    </rule> 
    </rules> 
</rewrite> 

例如,我的網站域名是www.example.com。在我的項目上啓用SSL後,我的網站現在是https://www.example.com。我的網站上有我的合作伙伴鏈接,如www.partner1.com。問題是,現在我的合作伙伴鏈接也在他們的網址https,但他們的網站沒有SSL證書,這意味着當我點擊他們的鏈接,我被重定向到一個https url,因此我有一個證書錯誤頁面。

如何設置我的域名只有https,並讓我的合作伙伴的href鏈接仍然使用http?因爲我用同樣的我已經與你的情況下檢查它的工作perfect..as你在答覆中提到

<rewrite> 
    <rules> 
    <clear /> 
     <rule name="Redirect to https" stopProcessing="true"> <match url=".*" /> 
     <conditions> <add input="{HTTPS}" pattern="off" ignoreCase="true" /> </conditions> 
     <action type="Redirect" url="https://{HTTP_HOST}{REQUEST_URI}" redirectType="Permanent" appendQueryString="false" /> 
    </rule> 
</rewrite> 

+0

嗨請檢查這個:https://finalcodingtutorials.blogspot.ae/2017/03/non-www-to-www-with-http-to-https.html –

+0

@Usman已經檢查這一個,這doesn解決我的問題,我網站上的每個鏈接仍然保持https .. – Huby03

+0

PLZ分享您的網站鏈接。 –

回答

0

我會建議你使用同樣的規則。

我在我的網站頁面上創建了一個鏈接,並將href設置爲http://域,這是另一個網站。它沒有改變,點擊該鏈接工作正常。這裏是鏈接代碼:

<a target="_blank" href="http:// www.jwoodmaker.com/">Test</a> 

因爲我已經發送給你鏈接哪些有這個完整的細節。 this link