Copied to clipboard

Flag this post as spam?

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


  • Michael 125 posts 409 karma points
    May 12, 2016 @ 15:07
    Michael
    0

    Multi language redirects

    Hi,

    I have web site with 2 language:

    1. mysite.com
    2. mysite.com/de

    Also I have Action filter which check User IP and if this IP from Germany we user go to mysite.com/de. So this is working.

    My problem is that I wold like to use main web site mysit.com/page1 for German users, because I don't have mysite.com/de/page1 node.

    Also I don't want to include this url(s) into redirect action filter to skip.

    Please advise....

    Thanks, Mike

  • Nicholas Westby 2054 posts 7104 karma points c-trib
    May 12, 2016 @ 16:04
    Nicholas Westby
    0

    Something like this might work:

    var request = UmbracoContext.Current.PublishedContentRequest;
    var found = ContentFinderResolver.Current.Finders.Any(x => x.TryFindContent(request));
    

    If the URL is found, you can continue with the normal redirect. If not found, you can redirect to the non-de version.

    Note that you may have to tinker with the above. I'm not sure if the list of finders includes the one that handles 404's (if so, found may always be true). Also, you may have to do something like clone the PublishedContentRequest and change the URL (e.g., if you need to add the "de" for the test).

    404 Alternative

    As an alternative, you could have your 404 page redirect to the non-de version of the page (if already on the non-de version of the page, the 404 would not do a redirect).

  • Michael 125 posts 409 karma points
    May 16, 2016 @ 15:23
    Michael
    0

    Hi,

    I found that getbyroute method can help me, but this method is not working for descendants. it works with "/" but didn't works with "/login/"

    UmbracoContext.Current.ContentCache.GetByRoute("/login/", true);

    Thanks, Mike

  • 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