Improve SEO for custom error pages - General Discussions - General Discussions - Progress Community
 General Discussions

Improve SEO for custom error pages

  • Improve SEO for custom error pages
  • 4c164f1e-37c1-6deb-a958-ff0000446526_capture.png

    Hey guys, 

    I don't know if this is the right section but I would like to ask if anybody knows the answer to this little issue i am experiencing.

    so basically when page is not found the sitefinity redirects to a custom Error page (404);  by
    using Fiddler, I noticed before landing on the Custom Error Page, the page I requested gets a 302 status.

    Having 302 followed by a 404 kind of sucks from an SEO perspective.

    I guess my question is, It is possible to make the 302 into 301 instead?

     

  • Hello Max,

    I could suggest to insert some code in your global.asax file. Something similar to this could do the trick:
    protected void Application_Error(object sender, EventArgs e)
        Exception ex = Server.GetLastError();
        if (ex is HttpException)
        
            var context = HttpContext.Current;
            context.Response.Clear();
            context.Response.Status = "301 Moved Permanently";
            context.Response.AddHeader("Location", "customErrorPage");
            context.Response.StatusCode = 301;
            context.Response.End();
        

    Hope this helps

    Regards,
    Vassil Vassilev
    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
     
  • Thank you for the reply,

    I used the code you provided but I still receiving 302 error then 404

    FYI: I have Sitefinity 5.1 i don't know if it helps or not.

     

  • Hello Max,

    Actually this should not be related with the Sitefinity version you are using. Here is a video of my test, which works as expected.

    Regards,
    Vassil Vassilev
    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