Do you have a custom 404 error page that you would like to use for your SharePoint site? If not, then don’t worry! This blog post will show you how to create one in no time to improve your site’s usability. A custom 404 page can be beneficial when a user mistypes your site’s address or clicks on a broken link. You can use it to provide information about the problem and how to fix it or simply direct users back to where they were supposed to go. In this blog post, we will walk you through the steps of creating a custom 404 error page for SharePoint.
It’s a best practice to show a customized 404 page not found error page for any website when a user requests a broken URL or mistyped URLs. SharePoint has no exclusions. By default, SharePoint gives this 404 error screen to the user:
So, It’s great to have a custom 404 Page not found error page in SharePoint 2010 to add some user experience, isn’t it? Let’s see how a custom 404 error page in SharePoint can be done:
1. Create an aspx page in Root site collection (say, “\SitePages\CustomError.aspx”). Add some descriptive images and text to it.
2. Go to IIS Manager, Backup the web.config file, and proceed with the following steps.
4. Double click on 404 status code
This will open the “Edit Custom Error Page” configuration window.
Change the option to:
“Execute a URL on this site” and specify the URL as: /SitePages/custom404.aspx (The Error page we have created!). Click Ok and quit IIS.
5. By now, If you open the web.config file, you can see the <httpErrors> section as:
<httpErrors> <remove statusCode="404" subStatusCode="-1" /> <error statusCode="404" prefixLanguageFilePath="" path="/SitePages/custom404.aspx" responseMode="ExecuteURL" /> </httpErrors>
Add these attributes to <httpErrors> node: errorMode=”Custom” existingResponse=”Auto” so, the modified code would be:
<httpErrors errorMode="Custom" existingResponse="Auto"> <remove statusCode="404" subStatusCode="-1" /> <error statusCode="404" prefixLanguageFilePath="" path="/SitePages/custom404.aspx" responseMode="ExecuteURL" /> </httpErrors>
6. Save web.config and do IISReset if needed. In fact, we can just skip the IIS console and place the above code directly in web.config! That’s all. We are done with the SharePoint custom page not found.
Once done, you should be able to get our custom 404-page content when you hit broken/deleted /mistyped URLs.