Setting a custom 404 error page for SharePoint
by Hojo Clement • August 9, 2010 • MOSS 2007, PowerShell • 1 Comment
In this article we will see how to set a custom error 404 (page not found) error page for SharePoint.
- Log on the sharepoint server and access the language folder in layout of IIS (% systemdrive%\Program Files\Common Files\Microsoft Shared\Web Server Extensions\12\TEMPLATE\LAYOUTS\LangID)
Note: In this path, LangID represents the actual Locale ID of the language that you use. For example, 1033 is the language ID for U.S. English. - Rename the error.html file to error.old.
- Create the custom HTML file (pagenotfound.html) and copy it to above folder.
- Create a console
- application / PowerShell script for assigning the new custom error page for your web application and run / execute it in SharePoint server
C# code for console application
Microsoft.SharePoint.Administration.SPWebApplication webapp =
Microsoft.SharePoint.Administration.SPWebApplication.Lookup(new Uri("http://"));
webapp.FileNotFoundPage = "pagenotfound.html";
webapp.Update();
PowerShell code
$webapp = [Microsoft.SharePoint.Administration.SPWebApplication]::Lookup("http://")
$webapp.FileNotFoundPage = "pagenotfound.html"
$webapp.Update()
Note: By default, in Internet Explorer, the Show friendly HTTP error messages setting is turned on and the custom error page may not appear. In this case turn off this setting and try.

Pingback: Tweets that mention Setting a custom 404 error page for SharePoint -- Topsy.com