Copied to clipboard

Flag this post as spam?

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


  • azeriker 3 posts 23 karma points
    Jun 29, 2021 @ 16:46
    azeriker
    0

    Force include locale in url

    I need to always redirect to page with locale in url

    Ex:

    I have a page with name "product1" I want to serve it for:

    • /products/product1
    • /{locale}/products/product1

    But!

    If user navigate to /products/product1

    I wanna redirect him to /{locale}/products/product1 where locale got from Accept-Lang header.

    What's best approach to get it done?

    I think I need to serve all my pages on my site with this rule

  • Dan Diplo 1554 posts 6205 karma points MVP 6x c-trib
    Jun 29, 2021 @ 18:39
    Dan Diplo
    0

    Is your site multilingual and set-up to have variants? If you have set-up multiple languages then you can right-click the Home node and select "Culture and Hostnames" and then add your locale as part of the domain.

    So if you wanted your URLs to start with /en/... then you'd add /en in the domain for the language English. Repeat for each language you wish to support.

    See https://our.umbraco.com/Documentation/Fundamentals/Backoffice/Variants/

    You can get the accept language from the Request.UserLanguages variable, if there are any,

  • azeriker 3 posts 23 karma points
    Jun 30, 2021 @ 07:59
    azeriker
    0

    Yeah, but if I will navigate to /products/product1 without locale set, I will get 404, but It should be redirect to /en/products/product1 as example

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies