tags:

views:

861

answers:

2

Is the best place set the 404 error page for SharePoint within the web.config customError section or is there a configuration setting on the site collection/ web application?

+4  A: 

Hi,

please have a read at this blog

pasted:

  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 asp.net 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"; webApplication.Update();

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

Ric Tokyo
A note of caution here: search bots that are following old urls won't get to your fancy aspx page (where you presumably redirect if you have a map of old/bad urls) since bots don't tend to execute javascript. I'm still working on a solution for this on my site.
Jon Dewees
why would you want search bots to index an error page?
Floetic
Brian, the error page helps for SEO results, when a page is not found: you still give something to the bot to continue moving on, and its best if you give something that indexes well to the rest of your site
Ric Tokyo
Should "http://MyMOSSServer/" be the name of the server or the name of the web site i created in sharepoint?
Rob
As far as I am concerned, this is not a valid solution. The server should be directly serving the page, javascript should not be used to redirect. My $0.02.
Dylan Berry
agreed, the best scenario is to have the IIS handle this
Ric Tokyo
A: 

I know this has already been answered but an alternative mgith be the following url: http://sharepointsmart404.codeplex.com/ - which should still result in a 404 status code so that search engines remove the page from their cache (eventually)

Mauro