Forum Discussion

Jim_P23's avatar
Jim_P23
Copper Contributor
Feb 01, 2023

using IIS URL Rewrite module for HTTP to HTTPS

I have installed the URL Rewrite module in IIS 10 to redirect HTTP calls to HTTPS, and I have attempted to set up the redirect but have not gotten it working on one server.  

 

Here is the issue:

Server1 with IP 1.1.1.1 is running IIS with an https enabled website. An outside DNS has assigned https://gohere.com to IP 1.1.1.1.  When users attempt to get to http://gohere.com the connection times out and it is not redirected to https://gohere.com

 

Accessing https://gohere.com works without an issue.

 

Here is the rewrite code from the web.config file. 

<rewrite>
<rules>
<rule name="HTTP to HTTPS" patternSyntax="Wildcard" stopProcessing="true">
<match url="http://gohere.com*" />
<conditions>
<add input="{HTTPS}" pattern="^OFF$" />
</conditions>
<action type="Redirect" url="https://gohere.com" appendQueryString="false" />
</rule>
</rules>
</rewrite>

 

I have also tried using match url=".*" 

 

Any ideas on what might be causing the issue? Or something to try to get it working?

 

Thanks!

 

Jim

 

 

2 Replies

  • KapildevMishra's avatar
    KapildevMishra
    Copper Contributor
    Hello Jim_p23
    kindly use below code which help you to achieve your goal.

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

    • Jim_P23's avatar
      Jim_P23
      Copper Contributor

      Thank you for the reply.

      I was able to get it to work. I had only set up HTTPS bindings but I also needed to have HTTP bindings enabled before it worked.

      Thank you again,

      Jim

Resources