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.


2018年1月18日 上午3:24 发件人 Apple 5. 1.1 Legal: Privacy - Data Collection and Storage Guideline 5.1.1 - Le...
  • u012576807
  • u012576807
  • 2016年03月24日 12:45
  • 13944

【极客学院】-python学习笔记-3-单线程爬虫 (request安装遇到问题及解决,应用requests提取信息)

极客学院课程网址: 任务: 爬取极客学院官方网站的课程库,并保存 Request...
  • aliceyangxi1987
  • aliceyangxi1987
  • 2016年01月12日 10:45
  • 1829

Django 安装使用基础

大纲 安装Django 1、创建Django工程 2、创建Django app 3、写一个简单的登录注册相应页面 4、获取用户请求信息并处理 5、前后端交互 6、Django 请求 生命周...
  • fgf00
  • fgf00
  • 2016年12月08日 18:35
  • 1764

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...
  • lanhaizhixing
  • lanhaizhixing
  • 2011年03月01日 13:40
  • 1149

(Redirect)How to create my own Corporate intranet(Site Definition In MOSS 2007)?( to create ...
  • jenny0810
  • jenny0810
  • 2011年02月12日 17:37
  • 1465

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...
  • u012025054
  • u012025054
  • 2013年11月05日 00:06
  • 1759

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...
  • jiabangok
  • jiabangok
  • 2012年05月08日 15:12
  • 1294

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

How to Create your Own Rule .pdf

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

Create Your Own Future How to Master the 12 Critical Factors of Unlimited Success

  • 2009年01月05日 15:24
  • 958KB
  • 下载
您举报文章:How to create your own custom 404 error page and handle redirect in SharePoint