Copied to clipboard

Flag this post as spam?

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


  • Martin Rud 261 posts 1022 karma points c-trib
    Nov 15, 2024 @ 09:19
    Martin Rud
    0

    bmsilo.fr does not hit correct culture, but bmsilo.com/fr does

    I have this setup for culture and hostnames: enter image description here

    "https://www.bmsilo.com/fr/" should be removed, but for now its needed since when I go to www.bmsilo.fr it renders English variant of content. Or as another example; when I go to https://www.bmsilo.fr/produits/silos I get 404 error (again; it tries to resolve to Enlgish content, and that is on url https://www.bmsilo.com/products/silos), but for https://www.bmsilo.com/fr/produits/silos I correctly get French content.

    Why is that?

    In my Program.cs I have this setup that might be relevant:

    if (app.Environment.IsProduction())
    {
        app.Use(async (context, next) =>
        {
            var request = context.Request;
            var host = request.Host.Value.ToLower();
            var path = request.Path.Value ?? string.Empty;
            var scheme = request.Scheme;
    
            // Ensure SSL
            if (scheme == "http" && !context.Request.Headers["X-Forwarded-Proto"].ToString().Equals("https", StringComparison.OrdinalIgnoreCase))
            {
                var newUrl = $"https://{host}{path}{request.QueryString}";
                context.Response.Redirect(newUrl, permanent: true);
                return;
            }
    
            // Ensure www
            if (!host.StartsWith("www."))
            {
                var newUrl = $"{scheme}://www.{host}{path}{request.QueryString}";
                context.Response.Redirect(newUrl, permanent: true);
                return;
            }
    
            await next();
        });
    }
    

    ...

  • Dennis Pedersen 5 posts 136 karma points
    Nov 15, 2024 @ 10:06
    Dennis Pedersen
    100

    removing the "/" one would fix that wouldnt it?

  • Martin Rud 261 posts 1022 karma points c-trib
    Nov 15, 2024 @ 10:15
    Martin Rud
    0

    Yes, that fixed it :)

    enter image description here

Please Sign in or register to post replies

Write your reply to:

Draft