How to create and configure a Custom 404 error page

Hi,

I'm new to Sitecore. Don't have a login so anything I request needs to go through web dev.

We have an issue on our site with Soft 404 pages. They are returning a 200 header status instead of a 404 status. If I type in a dummy URL, 200 status. Pages that used to exist and now don't - look like an error page but also return a 200 status.

Even the File Not Found 404 page in the public folder on the server returns a 200 status. https://www.site.com/public/404-file.html

Can I change something in Sitecore to make these pages return a 404 status?

 

Secondly, I would like to customize the page and include helpful links to other pages.

 

Thanks in advance!

  • - Don't have a login so anything I request needs to go through web dev - means you don't have access to login Sitecore or solution?

    Also few points I would like to understand can you create a new page in Sitecore also add code for same? If yes I can suggest to go and create a Item in Sitecore and add a control on it with c# code below -

    HttpContext.Current.Response.StatusCode = 404;
    HttpContext.Current.Response.TrySkipIisCustomErrors = true;
    HttpContext.Current.Response.StatusDescription = "404 File Not Found";


    And if you can't make any changes in Sitecore and solution and 404 page will always be .html page

    Try adding below config setting to your web.config file I haven;t checked it but it may help -

    <system.webServer>
    <httpErrors existingResponse="Replace">
    <remove statusCode="500" subStatusCode="-1" />
    <remove statusCode="404" subStatusCode="-1" />
    <error statusCode="404" prefixLanguageFilePath="" path="404.htm" responseMode="File" />
    <error statusCode="500" prefixLanguageFilePath="" path="500.htm" responseMode="File" />
    </httpErrors>
    </system.webServer>
  • Hi Chris,

    From the write I can understand that you had some URLs that are not working now. Is that your getting error as Layout not found or Document not found?

    If yes, then you can create a new page in Sitecore and design it's UI as 404 page. And use the path of this page in the value attribute of the following settings in Sitecore.config file.

    1. ItemNotFoundUrl
    2. LayoutNotFoundUrl

    Also as Yogeshwer said you can modify the httpErrors in Web.config file - This is optional though.

    Let me know in case you have any other queries