Microsoft Knowledge Base Email Alertz

KBAlertz.com: How to point to a custom 404 error Web page in Windows SharePoint Services 3.0 or in Microsoft Office SharePoint Server 2007

Receive Microsoft Knowledge Base articles by E-Mail?

Every night we scan the Microsoft Knowledge Base. If technologies you're interested in are updated, we'll send you an e-mail. You only get one e-mail a day, and only when new articles are added.

Click here to create a
FREE account
Already have an account?
[Click here to Login]

Search KbAlertz

Advanced Search

Webmasters
Put kbAlertz on your website.
[ Click Here for more! ]





ASP.NET 3.5 Web Hosting with Windows 2008 and SQL 2008: Click Here!
Discount ASP.NET Hosting
ASP.NET 2.0 and 3.5
Windows2008 and SQL2008
US and UK Hosting
The ad says 3 - but KBAlertz referrals get
** SIX MONTHS FREE **


Bug Tracking Software
For bug tracking software or defect tracking software or issue tracking software, visit Axosoft.


Community Site



We Send hundreds of thousands of emails using ASP.NET Email



Expert Web Design & Graphic Design
Design44.com

ASP.NET 3.5 Web Hosting with Windows 2008 and SQL 2008: Click Here!
Discount ASP.NET Hosting
ASP.NET 2.0 and 3.5
Windows2008 and SQL2008
US and UK Hosting
The ad says 3 - but KBAlertz referrals get
** SIX MONTHS FREE **




Mentioned In








Microsoft Knowledge Base Article

This article contents is Microsoft Copyrighted material.
©2005-©2007 Microsoft Corporation. All rights reserved. Terms of Use | Trademarks




Article ID: 941329 - Last Review: June 16, 2008 - Revision: 2.0

How to point to a custom 404 error Web page in Windows SharePoint Services 3.0 or in Microsoft Office SharePoint Server 2007

INTRODUCTION

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

MORE INFORMATION

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.

    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. Add the custom content to the Custom404.html file.
    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 as required.
    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:
    http://msdn2.microsoft.com/en-us/library/ms438026.aspx (http://msdn2.microsoft.com/en-us/library/ms438026.aspx)
    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  (http://kbalertz.com/Feedback.aspx?kbNumber=218155/ ) Description of Hypertext Transport Protocol Error Messages

APPLIES TO
  • Microsoft Office SharePoint Server 2007
  • Microsoft Windows SharePoint Services 3.0
Keywords: 
kbexpertiseinter kbhowto KB941329
       

Community Feedback System

Very often, it takes hours to solve a problem. Very often, you've looked high and low, and have tried a lot of solutions. When you finally found it, chances are, it was because someone else helped you. Here's your chance to give back. Use our community feedback tool to let others know what worked for you and what didn't.

Please also understand that the community feedback system is not warranted to be correct, it's simply a system that we've built to let people try and help each other. If something in a feedback response doesn't make sense to you, or you're not comfortable making changes that the feedback talks about (like registry edits), please consult a professional.

Thank you for using kbAlertz.com Feedback System.

-- Scott Cate

Pratap Raju Report As Irrelevant  
Written: 6/12/2008 3:34 PM
This seems to be working within a site collection context only, i.e. http://server/sites/mysite if mysite doesn't exist in MOSS then this URL will NOT trigger the error page set to SPWebApplication.FileNotFoundPage property(custom404.html). SPUtilityInternal Send404 will return a string "404 FILE NOT FOUND".

KodeKreachor Report As Irrelevant  
Written: 9/26/2008 12:11 PM
Unfortunately this solution will not do any good if the client has the 'Show friendly HTTP error messages' option enabled in IE. Can anyone prove this statement wrong?

(Optional) Name

(Optional) Public URL Or Email

Comments
No HTML -- Text Only Please