locked
Rewrite rule to redirect from HTTPS to HTTP RRS feed

  • Question

  • User604186779 posted

    I would like to redirect the user if they try to browse the URL with HTTPS://www.domain.com/testpage.aspx we need to redirect user with the HTTP://www.domain.com/testpage.aspx.

    Can you please correct the rewrite rule which has been mentioned below.

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


    Tuesday, May 15, 2018 2:31 PM

Answers

  • User283571144 posted

    Hi venkatu2005,

    Could you please tell me which ssl you have used for your web application?

    Do you use the CloudFlare ssl?

    As far as I know, the CloudFlare at a minimum uses flexible SSL. This means that the end user, browser shows the SSL lock but your server doesn't need SSL.

    Without using that, below redirect rule will work well.

    <rule name="HTTPS to HTTP redirect" stopProcessing="true">
    <match url="(.*)" />
    <conditions>
    <add input="{HTTPS}" pattern="on" ignoreCase="true" />
    </conditions>
    <action type="Redirect" redirectType="Found" url="http://{HTTP_HOST}/{R:1}" />
    </rule>

    More details, you could refer to below article.

     https://www.cloudflare.com/ssl/ 

    Best Regards,

    Brando

    Best Regards,

    Brando

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, May 28, 2018 5:01 AM

All replies

  • User-718146471 posted

    You could try this:

    <!-- http:// to https:// rule -->
    <rule name="ForceHttpsBilling" stopProcessing="true">
      <match url="(.*)billing/(.*)" ignoreCase="true" />
      <conditions>
        <add input="{HTTPS}" pattern="off" ignoreCase="false" />
      </conditions>
      <action type="Redirect" redirectType="Found" url="https://{HTTP_HOST}{REQUEST_URI}" />
    </rule>
    
    <!-- https:// to http:// rule -->    
    <rule name="ForceNonHttps" stopProcessing="true">
      <match url="(.*)billing/(.*)" ignoreCase="true" negate="true" />
      <conditions>
          <add input="{SERVER_PORT}" pattern="^443$" />
      </conditions>
      <action type="Redirect" redirectType="Found" url="http://{HTTP_HOST}{REQUEST_URI}" />
    </rule>

    from https://stackoverflow.com/questions/1536120/rewriting-urls-from-https-to-http-in-iis7

    Tuesday, May 15, 2018 6:04 PM
  • User604186779 posted

    It's not working.

    If user try like this https://www.domain.com/test.aspx I need to redirect the user with HTTP http://www.domain.com/test.aspx

    Thursday, May 17, 2018 7:39 PM
  • User283571144 posted

    Hi venkatu2005,

    Could you please tell me which ssl you have used for your web application?

    Do you use the CloudFlare ssl?

    As far as I know, the CloudFlare at a minimum uses flexible SSL. This means that the end user, browser shows the SSL lock but your server doesn't need SSL.

    Without using that, below redirect rule will work well.

    <rule name="HTTPS to HTTP redirect" stopProcessing="true">
    <match url="(.*)" />
    <conditions>
    <add input="{HTTPS}" pattern="on" ignoreCase="true" />
    </conditions>
    <action type="Redirect" redirectType="Found" url="http://{HTTP_HOST}/{R:1}" />
    </rule>

    More details, you could refer to below article.

     https://www.cloudflare.com/ssl/ 

    Best Regards,

    Brando

    Best Regards,

    Brando

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, May 28, 2018 5:01 AM
  • User753101303 posted

    Hi,

    Never tried but IMO the issue is that if https is not configured, then the rewriting rule can't kick in and if configured it is then best to stick with https. Have you tried to see first if the https request reaches your server? (or can you make it so ?)

    Monday, May 28, 2018 11:15 AM