1
votes

I have created and ASP.NET Core project and i purchased a SSL for my website. I have created a redirect rules in my web.config to redirect my http to https. The issue i have is that every link on my website now have https which cause certificate issues since some of those links don't have ssl. This is what i've done:

<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>

For example, my website domain is www.example.com. After enabling SSL on my project, my website is now https://www.example.com. I have some links on my website for my partners such as www.partner1.com. The problem is that now my partners link also have https in their url but their website does not have SSL certificate which means when i click on their links, i am redirected to a https url and therefore i have a certificate error page.

How can i set my domain to only have https and let my partners a href link still use http?

1
@Usman Already check this one, this doesn't solve my issue, every link on my website still remain https..Huby03
plz share your website link.UsmanMirza
also plz give some link details which you mention evey link on your website is now https..this is making little confusion..make some scenario or example and share.UsmanMirza
@UsmanMirza Unfortunately i cannot share the website for specific reason. I have updated my question with an example. Thank youHuby03

1 Answers

0
votes

i would suggest you to use this same rule:

 <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> 

because i am using same and i already check with your scenario it's working perfect..as you mentioned in your answer.

i created a link on my website page and set that a href to a http:// domain which is another website. its not changing and on click that link working fine. here is link code:

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

as i already send you link which have full details of this. this link