Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Dmitriy 135 posts 510 karma points
    Apr 19, 2019 @ 13:38
    Dmitriy
    0

    IIS rewrite redirect looping (too many redirects)

    Hello, Umbracians

    Here is my rewrite rule:

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

    Fore some reason time to time it throws "too many redirects". I have tryed several recomedation, but it's does't works for me.

    P.S.

    Solutuion has 301 redirect package on board, may be it is important

  • Ambert van Unen 16 posts 189 karma points
    Apr 19, 2019 @ 16:00
    Ambert van Unen
    100

    Try the code below, it has always worked for me. Not sure why you get an loop though. Maybe caching, close ALL incognito, and open a new screen and try it again each time. Your browser might be caching the redirect:

    <rule name="RedirectHttpToHttps" stopProcessing="true">
              <match url="(.*)" />
              <conditions>
                <add input="{HTTPS}" pattern="off" ignoreCase="true" />
              </conditions>
              <action type="Redirect" url="https://{HTTP_HOST}/{R:1}" redirectType="Permanent" />
            </rule>
    
  • Dmitriy 135 posts 510 karma points
    Jun 13, 2019 @ 09:07
    Dmitriy
    0

    Seems you are right about caching, it works for me

    Thanks!

Please Sign in or register to post replies

Write your reply to:

Draft