2017-04-12 51 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