Copied to clipboard

Flag this post as spam?

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


  • Asmi-Sharma 1 post 21 karma points
    5 days ago
    Asmi-Sharma
    0

    Rewrite rules Umbraco 13

    Hi,

    I created a web.config file on root of the project and then wrote the rewrite rules in a local clone. After I push it to live environment it does not reflect the rules written.

    My web.config file is:

    web.config

    web.config

    Problem is: When I search for xyz.nl it should redirect to https://www.xyz.nl, but it does not redirect.

  • Sergey 6 posts 77 karma points
    2 days ago
    Sergey
    0

    Hi!

    Does asp.net core support classic's asp.net configs? I don't think so. You could achieve redirect in .net core app in multiple ways, but if you want something close to classy way, then do following:

    Create IISUrlRewrite.xml in a root of your site. Name can be any, but content will be following:

    <?xml version="1.0" encoding="utf-8" ?>
    <rewrite>
        <rules>
            <!-- Your rules here -->
        </rules>
    </rewrite>
    

    Add rewriter pipeline to Program.cs:

    WebApplication app = builder.Build();
    await app.BootUmbracoAsync();
    
    var rewriteOptions = new RewriteOptions()
        .AddIISUrlRewrite(app.Environment.ContentRootFileProvider, "IISUrlRewrite.xml");
    app.UseRewriter(rewriteOptions);
    app.UseStaticFiles();
    
Please Sign in or register to post replies

Write your reply to:

Draft