+1-888-365-2779
Try Now
More in this section

Forums / General Discussions / Can missing language-specific pages fallback to default language?

Can missing language-specific pages fallback to default language?

7 posts, 0 answered
  1. Chris
    Chris avatar
    3 posts
    Registered:
    23 Apr 2014
    15 Jun 2015
    Link to this post

    We've added a new language. We want missing pages to be redirected to the English equivalent. For example, if ~/zh/Services is missing, we want them redirected to ~/en/Services. Right now the user gets a 404 error.

    We don't want to have to do this manually for every page. Is there some global setting we can use, or some code we can add?

     

    Hm, no replies? So...is our only choice to manually instantiate zh versions of every page, and have each redirect to the existing en version?

  2. Junior Dominguez
    Junior Dominguez avatar
    115 posts
    Registered:
    02 Dec 2016
    17 Jun 2015
    Link to this post
    Hi Chris,

    You can try redirecting to the desired page in the Application_Error event in global.asax. E.g:

    protected void Application_Error(object sender, EventArgs e)
           {
               var ex = Server.GetLastError() as HttpException;
               if (ex != null)
               {
                   int httpCode = ex.GetHttpCode();
                   if (httpCode == 404)
                   {
                        
                       string urlSegment = this.Context.Request.Url.Segments[this.Context.Request.Url.Segments.Length-1];
     
                       this.Context.Response.Redirect("/en/" + urlSegment);
                   }
               }
     
           }


    Regards,
    Junior Dominguez
    Telerik
     
    Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Sitefinity CMS Ideas&Feedback Portal and vote to affect the priority of the items
     
  3. Chris
    Chris avatar
    3 posts
    Registered:
    23 Apr 2014
    19 Jun 2015 in reply to Junior Dominguez
    Link to this post

    Thanks, I'll try that!

    EDIT: Not working yet.

    I added the global.asax,  added your code to the Application_Error handler, and rebuilt. I made one change, because I think a true 404 would otherwise cause an infinite loop:

    if (httpCode == 404)
    {
        if (this.Context.Request.Url.Segments[1] == "zh/")
        {
            string urlSegment = this.Context.Request.Url.Segments[this.Context.Request.Url.Segments.Length - 1];
            this.Context.Response.Redirect("/en/" + urlSegment);
        }
    }

    But this hasn't made a difference, I still see the 404 page with the same missing URL. (I also restarted IIS, just to be sure.)

  4. Junior Dominguez
    Junior Dominguez avatar
    115 posts
    Registered:
    02 Dec 2016
    24 Jun 2015
    Link to this post
    Hi Chris,

    Can you please provide some feedback about your results ? What happen when you debug it ? Is it redirecting to another location? 

    Best Regards,
    Junior Dominguez
    Telerik
     
    Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Sitefinity CMS Ideas&Feedback Portal and vote to affect the priority of the items
     
  5. Patrick
    Patrick avatar
    1 posts
    Registered:
    03 Mar 2016
    07 Apr
    Link to this post

    Is there another solution to this problem?

    I do not like the "Application_Error" solution - I should not have to manually redirect to the English version of the page.

     

    Furthermore, redirecting to the "en" version, will put Sitefinity in English mode.  This causes problems if you are using a language-specific .resx file.  For example, if a user requests "/fr/home" and I redirect them to "/en/home" it means that the English version of my .resx files will be chosen, which is not the desired result.

  6. Junior Dominguez
    Junior Dominguez avatar
    115 posts
    Registered:
    02 Dec 2016
    14 Apr
    Link to this post
    Hi Patrick,

    You may consider the alternatives described in the following link of our documentation and customize the error message depending on the culture in the widget:

    http://docs.sitefinity.com/administration-custom-error-pages

    Best Regards,

    Junior Dominguez
    Telerik
     
    Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Sitefinity CMS Ideas&Feedback Portal and vote to affect the priority of the items
     
  7. Jayson
    Jayson avatar
    3 posts
    Registered:
    23 Oct 2015
    17 Aug
    Link to this post

    Hi Guys,

    What i did was I created a Redirect Widget and put it inside the page. So this translated page will redirect to wherever i like.

    Just a quick fix i can't find a solution to this right now. Any suggestion?

    Thanks

7 posts, 0 answered