SharePoint 2013 Redirect user to custom PageNotFoundError page

This SharePoint Online tutorial explains, how to redirect the user to custom PageNotFoundError page in SharePoint 2013/2016.

In this article, I would like to walk you through the process to change the default page not found the error to user-customized page not found error with user message In SharePoint 2013/2016.

You all might be thinking why a user will get this scenario as page not found error below are the various scenarios:

  • Page deleted by admin
  • Change in URL of a hyperlink

The default page not found error will be rendered as below:

Replace default PageNotFoundError.aspx with Custom Error Page in SharePoint 2013
Replace default PageNotFoundError.aspx with Custom Error Page in SharePoint 2013

This might not be ok with every user and some want to show their own custom error page.

Follow the below approach to change the default error page to a different with user requirement.

This we can achieve in 3 different ways:

  1. Replace the default pagenotfounderror page
  2. Update the default error page using PowerShell
  3. Change the file not found error page in SharePoint designer 2013

Replace default PageNotFoundError page in Pages library

In SharePoint as soon as you enable publishing features you can see a default error page in Pages library with the path “<<Site URL>>/Pages/PageNotFoundError.aspx”.

Follow the below steps to change the default page:

1. Logon on to SharePoint site
2. Open Site content
3. Click on Pages Library
4. Delete the existing “PageNotFoundError” page
5. Create a new error page by clicking on “Error Page” option.

sharepoint 2016 custom error page
SharePoint 2013 Redirect user to custom PageNotFoundError page

Update default error page using PowerShell

The issue or drawback with the above approach is we will be losing the default error page in SharePoint 2013.

We can update the default association of pageNotfoundError page using the below PowerShell commands to a custom or user-defined page.

Create a custom page “userErrorPage” by following the steps 3 to 6.

sharepoint 2013 custom error page
sharepoint online custom error page

Once you create the custom error page execute the below commands to change the default association.

Syntax:

$objSpSite = Get-SPSite "<<Web site URL>>"
$objSpSite.filenotfoundurl << This will show the existing file not found error page >>
$objSpSite.filenotfoundurl = "<<Custom error page URL>>"
custom filenotfound error page
custom filenotfound error page

Example:

$objSpSite = Get-SPSite “http://sharepoint13:12345/sites/vspsc/"
$objSpSite.filenotfoundurl = "/sites/vspsc/Pages/userErrorPage.aspx"
$objSpSite.filenotfoundurl
$objSpSite.close()
Replace default PageNotFoundError.aspx with Custom Error Page in SharePoint
Replace default PageNotFoundError.aspx with Custom Error Page in SharePoint 2013

Change file not found error page in SharePoint designer

With the new Site Options in SharePoint Designer 2013, you can assign the vti_filenotfoundpage property of the site to a Custom Error Page that you might have deployed in the 15 Hive.

Simply Open your Site in Designer and Under “Site Options” -> Parameters(tab) modify ‘vti_filenotfoundpage’ property to add a relative URL to your Custom error Page deployed in 15 Hive. See the Screen below.

sharepoint online custom error page
SharePoint 2013 Redirect user to custom PageNotFoundError page Tutorial
SharePoint 2016 Redirect user to custom PageNotFoundError page
SharePoint 2016 Redirect user to custom PageNotFoundError page Tutorial

The output will be as follows:

custom filenotfound error page
custom filenotfound error page

Hope this helps, happy development in SharePoint !!!!

You may like following SharePoint tutorials:

Donwload Hub site pdf

Download SharePoint Online Tutorial PDF FREE!

Get update on Webinars, video tutorials, training courses etc.

  • How do I redirect using Site Option. By default the question mark link taking me to /_layouts/15/help.aspx?Lcid=1033&Key=WSSEndUser&ShowNav=true and I wanted to redirect to a custom page.

  • >