Notice: This website is an unofficial Microsoft Knowledge Base (hereinafter KB) archive and is intended to provide a reliable access to deleted content from Microsoft KB. All KB articles are owned by Microsoft Corporation. Read full disclaimer for more details.

How to point to a custom 404 error Web page in SharePoint


View products that this article applies to.

INTRODUCTION

This article describes how to point to a custom 404 error Web page in Windows SharePoint Services 3.0, in Microsoft Office SharePoint Server 2007, or in Microsoft SharePoint Server 2010.

↑ Back to the top


More Information

Windows SharePoint Services 3.0 or SharePoint Server 2007

To configure Windows SharePoint Services 3.0 or SharePoint Server 2007 to point to a custom 404 error Web page, follow these steps.

Note Because of a design limitation, the custom 404 error Web page does not work when you access invalid site collections.
  1. Log on to the computer that is running SharePoint Server 2007 by using an account that has administrative permissions.
  2. In Windows Explorer, locate the following folder:
    %systemdrive%\Program Files\Common Files\Microsoft Shared\Web Server Extensions\12\TEMPLATE\LAYOUTS\LangID
    Notes
    • In this path, %systemdrive% represents the actual drive name of the drive on which the operating system is installed.
    • In this path, LangID represents the actual language ID of the language that you use. For example, 1033 is the language ID for U.S. English.
  3. Create the custom HTML file. To do this, use the appropriate method. Refer to the examples below for each version of SharePoint:

    Microsoft Office SharePoint Server 2007

    1. On the computer that is running SharePoint Server 2007, copy the Sps404.html file to a temporary folder.
    2. Rename the Sps404.html file. For example, give the file the following name:
      Custom404.html
    3. Modify the Custom404.html file to suit your needs for a custom 404 error message using an HTML editor.
    4. Copy the Custom404.html file to the %systemdrive%\Program Files\Common Files\Microsoft Shared\Web Server Extensions\12\TEMPLATE\LAYOUTS\LangID folder.

    Windows SharePoint Services 3.0

    1. On the computer that is running Windows SharePoint Services 3.0, locate the existing Error.htm file in the following folder:
      %systemdrive%\Program Files\Common Files\Microsoft Shared\Web Server Extensions\12\TEMPLATE\LAYOUTS\LangID
      Notes
      • In this path, %systemdrive% represents the actual drive name of the drive on which the operating system is installed.
      • In this path, LangID represents the actual language ID of the language that you use. For example, 1033 is the language ID for U.S. English.
    2. Copy the Error.htm file to a temporary folder.
    3. Rename the Error.htm file. For example, give the file the following name:
      Custom404.htm
    4. Modify the Custom404.htm file to suit your needs for a custom 404 error message using an HTML editor.
    5. Copy the Custom404.htm file to the %systemdrive%\Program Files\Common Files\Microsoft Shared\Web Server Extensions\12\TEMPLATE\LAYOUTS\LangID folder.
  4. Create a custom console application by using Microsoft Visual Studio 2005 Professional Edition or Microsoft Visual Studio 2005 Standard Edition. Then, add the following code to the custom console application.
    // The following code assumes that a reference is made to Microsoft.SharePoint.

    Microsoft.SharePoint.Administration.SPWebApplication webapp =
    Microsoft.SharePoint.Administration.SPWebApplication.Lookup(new Uri("http://<serverurl>"));
    webapp.FileNotFoundPage = "<Custom404.htm>";
    webapp.Update();
    Notes
    • In this code, <serverurl> represents the actual URL of the computer that is running SharePoint Server 2007.
    • In this code, <Custom404.htm> represents the actual name that you created for the custom HTML file.
    For more information about how to create a custom console application by using Visual Studio 2005, visit the following Microsoft Web site:Note By default in Windows SharePoint Services 3.0 and in SharePoint Server 2007, the FileNotFoundPage property is set to the "null" setting.
  5. Run the custom console application on the computer that is running SharePoint Server 2007.
Note By default in Windows Internet Explorer, the Show friendly HTTP error messages setting is turned on. In this case, the custom error page may not appear. For more information about this setting, click the following article number to view the article in the Microsoft Knowledge Base:

218155 Description of Hypertext Transport Protocol Error Messages

SharePoint Server 2010

To configure SharePoint Foundation server or SharePoint Server 2010 to point to a custom 404 error Web page, follow these steps.   
  1. Log on to the computer that is running SharePoint Server 2010 by using an account that has administrative permissions. 
  2. In Windows Explorer, locate the following folder: 

    %systemdrive% \Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\TEMPLATE\LAYOUTS\LangID 

    Notes

    • In this path, %systemdrive% represents the actual drive name of the drive on which the operating system is installed.  

    • In this path, LangID represents the actual language ID of the language that you use. For example, 1033 is the language ID for U.S. English. 
  3. Create the custom HTML file:
    1. On the computer that is running SharePoint Server 2010, copy the Sps404.html file to a temporary folder. 
    2. Rename the Sps404.html file. For example, give the file the following name: 

      Custom404.html
    3. Modify the Custom404.html file to suit your needs for a custom 404 error message using an HTML editor.
     
  4. Copy the Custom404.html file to the %systemdrive% \Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\TEMPLATE\LAYOUTS\LangID folder.
  5. Run the following PowerShell commands from the SharePoint 2010 Management Shell:
    $webapp =Get-SPWebApplication http://<serverUrl>:<port>
    $webapp.FileNotFoundPage = "Custom404.html"
    $webapp.update()


    Verify that the property is set by running the following command:

    (Get-SPWebApplication http://<serverUrl>:<port>).FileNotFoundPage



    Notes

    • In this code, <serverUrl> represents the actual URL of the Web application where you are setting the custom 404 error page. 

    • In this code, <port> represents the nonstandard port number, if any, that is assigned to the Web application. 

    • In this code, Custom404.html represents the actual name that you created for the custom HTML file.  

    For more information about how to use PowerShell scripts against SharePoint 2010, visit the following Microsoft Web site: 

    Windows PowerShell for SharePoint Foundation 2010

    Note By default in SharePoint Server 2010, the FileNotFoundPage property is set to the "null" setting.
 

↑ Back to the top


Keywords: kbentirenet, kbexpertiseinter, kbhowto, kb

↑ Back to the top

Article Info
Article ID : 941329
Revision : 3
Created on : 4/18/2018
Published on : 4/19/2018
Exists online : False
Views : 477