Copied to clipboard

Flag this post as spam?

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


  • Henning Molbaek 48 posts 97 karma points
    1 week ago
    Henning Molbaek
    0

    Internal error on https redirects

    Hi,

    For some reason I get an Internal 500 error when I try to add the following to the web config on a Umbraco V8 site:

    <rewrite>
         <rules>
                <rule name="HTTP to HTTPS redirect" stopProcessing="true">
      <match url="(.*)" />
      <conditions>
        <add input="{HTTPS}" pattern="off" ignoreCase="true" />
        <add input="{HTTP_HOST}" pattern="localhost" negate="true" />
      </conditions>
      <action type="Redirect" url="https://{HTTP_HOST}/{R:1}" redirectType="Permanent" />
    </rule>
                </rules>
            </rewrite>
    

    I have never had any issues with this on version 7. Any ideas? I run this on Windows 2019 server with latest updates.

    Note: The site works great with https if I type it into the browser.

  • Patrick van Kemenade 33 posts 164 karma points
    1 week ago
    Patrick van Kemenade
    0

    Dear Henning,

    Your code is pretty similar with what I use on my live server Umbraco v8, here is my code:

            <rule name="HTTP to HTTPS redirect" stopProcessing="false">
          <match url="(.*)" />
          <conditions>
            <add input="{HTTPS}" pattern="^OFF$" />
            <add input="{HTTP_HOST}" matchType="Pattern" pattern="^localhost(:\d+)?$" negate="true" />
            <add input="{HTTP_HOST}" matchType="Pattern" pattern="^127\.0\.0\.1(:\d+)?$" negate="true" />
          </conditions>
          <action type="Redirect" url="https://{HTTP_HOST}/{R:1}" redirectType="Permanent" />
        </rule>
    

    Could you try mine version, see if it works and if so one by one change it back to your version to see where it breaks.

    Also where are you getting the 500 error on the frontend or the backend ?

    Also a thing to add (also the health check was writing error in my log on localhost is this):

    <appSettings>... other settings ...<add key="Umbraco.Core.UseHttps" value="true" /></appSettings>
    

    Another thinh to note is that you have set stopProcessing to true, is this the last rule in rules ? Otherwise other rules which needed to fire are maybe prevented by this rule causing the error.

    Please let me kno what the issue is. And if anybody has feedback or improvements on my rewrite https code please let me know also.

  • Henning Molbaek 48 posts 97 karma points
    1 week ago
    Henning Molbaek
    0

    What would the correct one be for:

    1. It is the only rule.
    2. It is not a localhost site but a live domain.
  • Patrick van Kemenade 33 posts 164 karma points
    1 week ago
    Patrick van Kemenade
    0

    I use this one on both my localhost and on my live website.

    Have you tried what happens if you change your rule with my code, do you get the same error ?

  • Henning Molbaek 48 posts 97 karma points
    1 week ago
    Henning Molbaek
    0

    Same error. It is on the frontend.

  • Patrick van Kemenade 33 posts 164 karma points
    1 week ago
    Patrick van Kemenade
    0

    Then I'm pretty sure the error isn't in the rewrite rule but somewhere else.

    Have you tried to trouble shoot it by accessing a static resource http://<your-site>/images/yourimage.jpg then you at least know if the bindings and routing is working.

    Note, you also double checked you have both the http and https bindings in IIS ?

    Also does the umbraco log, log anything. If not next step is the windows log.

Please Sign in or register to post replies

Write your reply to:

Draft