How to create your own custom 404 error page and handle redirect in SharePoint

转载 2015年07月08日 00:22:20


1. In your MOSS server, make a copy of

%systemdrive%\Program Files\Common Files\Microsoft Shared\Web Server Extensions\12\TEMPLATE\LAYOUTS\1033\sps404.html

and call it my404.html


2. Create a Virtual Directory in IIS under your MOSS root web application. For example /errors

3. Create your own redirect aspx page, for example /errors/my404redirect.aspx and code your redirect logic in there. This is a normal page. 

4. In my404.html, make the following change:

            STSNavigate("/errors/my404redirect.aspx?oldUrl=" + requestedUrl);

5. Create a Console Application and insert the following code and run it in MOSS server


           System.Uri webApplicationUri = new Uri(http://MyMOSSServer/);

           SPWebApplication webApplication = SPWebApplication.Lookup(webApplicationUri);

           webApplication.FileNotFoundPage = "my404.html";  //*note


*Note: By default this is set to null. FileNotFoundPage needs to point to a html file that lives in %systemdrive%\Program Files\Common Files\Microsoft Shared\Web Server Extensions\12\TEMPLATE\LAYOUTS\1033. The file needs to be html only.


6. Now when you browse to a page that doesn't exist, you should expect to be brought to the redirected page.


 *Another note:

In IE there's a "Show friendly HTTP error messages" setting which is ON by default in Internet Options->Advanced. With this setting on, sometimes your custom error page is not displayed. In order to override this setting, both my404.html and /errors/my404redirect.aspx from the above steps need to be larger than 512 bytes in size. Refer to the following KB about this setting: 

* This seems to be working within a site collection context only, i.e.http://MyMOSSServer/sites/siteA if sites is a wildcard inclusion managed path and siteA doesn't exist in MOSS then this URL will NOT trigger the custom 404 error page set to SPWebApplication.FileNotFoundPage property.


How to redirect to a Custom Page for Event Receiver in SharePoint 2010

Introduction:An event receiver in SharePoint allows great flexibility to meet various user requireme...

(Redirect)How to create my own Corporate intranet(Site Definition In MOSS 2007)?( to create ...

How to create custom navigation menu in SharePoint with XML data source 使用XML数据源在SharePoint创建自定义导航菜单

How to create custom navigation menu in SharePoint with XML data source Did you ever wanted to crea...

How to add custom fields to Customer Registration and Account page in magento

经过测试,一下的代码在magento CE1.4 1.5 1.6 均好使 Magento Provides the default customer registration form with...

How to Create your Own Rule .pdf

  • 2009年03月23日 10:35
  • 325KB
  • 下载

How To Create Your Own Personal Document Viewer (Like Scribd or Google Books)
  • dipolar
  • dipolar
  • 2012年07月16日 16:20
  • 764

SAP CRM How to Create your own BOL Object for webclient

from: Using the BOL...

unity kinect2 怎么使用姿势或者使用你自己的How to Use Gestures or Create Your Own Ones

首先说明这是unity kinect的一个商业插件 使用的是2.5版本的 这里翻译的是How to Use Gestures or Create Your Own Ones的文档 有两种方式可以...

HOWTO: How to Provide Your Own DllMain in an MFC Regular DLL Additional care must be taken when relying on DllMai...
  • jiht594
  • jiht594
  • 2011年08月27日 09:57
  • 389
您举报文章:How to create your own custom 404 error page and handle redirect in SharePoint