Copied to clipboard

Flag this post as spam?

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


  • Thomas M. Pedersen 11 posts 111 karma points
    Apr 07, 2023 @ 10:38
    Thomas M. Pedersen
    0

    Im trying to build some redirects in umbraco 11.2.2

    But its like they do not get picked up, and no matter what i do i see the "Page Not Found" site.

    I did try to install Skybrud.Umbraco.Redirects 4.0.8 and nothing working when i create redirects.

    I also try the middleware solution with: new RewriteOptions().AddIISUrlRewrite(env.ContentRootFileProvider, "Rewrites.xml"); in startup.cs but that not working either for some reason.

    Anyone have an idea what could be wrong? It's a multilingual site and I wonder if that could be the problem because I have another single language site where all is working fine.

  • Dhanesh Kumar MJ 158 posts 511 karma points c-trib
    Apr 10, 2023 @ 17:47
    Dhanesh Kumar MJ
    100

    Hi Thomas,

    Need to call

    app.UseStaticFiles();

    Try the following code.

    1. Create a new extension Method (it's your choice)

      public static void ApplyRewriteRules(this IApplicationBuilder app)
      {
              using (StreamReader iisUrlRewriteStreamReader =
                  File.OpenText("IISURLRewrite.xml"))
              {
                  var options = new RewriteOptions()
                      .AddRedirectToHttpsPermanent()
                  .AddIISUrlRewrite(iisUrlRewriteStreamReader);
      
      
      
              app.UseRewriter(options);
          }
          app.UseStaticFiles();
      } 
      
    2. Call the created extension method ApplyRewriteRules before the app.UseUmbraco();

          //add custom iis rules
          app.ApplyRewriteRules();
      
  • Thomas M. Pedersen 11 posts 111 karma points
    Apr 10, 2023 @ 20:29
    Thomas M. Pedersen
    0

    Thanks, got it to work now ;-)

Please Sign in or register to post replies

Write your reply to:

Draft