• Setting a custom 404 error page for SharePoint

    by  • 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.

    1. 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.
    2. Rename the error.html file to error.old.
    3. Create the custom HTML file (pagenotfound.html) and copy it to above folder.
    4. Create a console
    5. 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.

    About

    Hojo Clement was working in US Technology in Trivandrum as a Senior Software Engineer. He has 6 years experience in working with Web Development Technologies inlcuding MOSS and ASP.net.

    One Response to Setting a custom 404 error page for SharePoint

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

    Leave a Reply

    Your email address will not be published. Required fields are marked *