in

SharePoint Blogs

The Best Place for SharePoint-related Blogs

Michael Hofer - SharePoint Blog

Michael Hofer's blog about adventures in SharePoint land, including tips and tricks for all products and technologies used in Information Worker solutions.

Creating custom 404 and landing pages (easy to remember URLs that are redirected) in SharePoint

This post is about how to create custom landing pages (www.mysite.com/products or www.mysite.com/newsletter) that directs the visitor through and easy to remember URL to any page  in your deep site hierarchy. It also contains the approach how to create custom 404 "Page not found" pages.

In this bost, I'll only explain you the concepts, since I don't really know if I get to code this within a reasonable timeframe. Next week, I'll start at Microsoft, so I'm not sure to have plenty of time for trying things out in the next weeks...

 OK, what are we talking about: SharePoint URLs get constructed today a lot better than before. However, it is still not easily possible to create so called "landing pages". These are mostly just entry points that let a visitor easily find its content. Marketing campaigns can print easy to remember URLs on their advertisements etc. Need some examples? OK, here we go:

www.mycompany.com/winthis -- leads to --> www.mycompany.com/marketing/campaigns/summer07/signup.aspx
www.mycompany.com/subscribe -- leads to --> www.mycompany.com/salesandmarketing/ebusiness/newsletters/english/signup.aspx

How should we do this? If you enter such an URL in MOSS you'll get a 404 error. Of course, because this pages do not exists. You couldn't work with Redirect Pages either because they would be located in the "Pages/" section of any site.

Here is now my concept to implement this:

  • Customize the 404 landing page (I follow Jingmei's post): Create your "custom404.html" page. It must be a HTML page that redirects the requsts, cannot be an ASPX page!
  • Create a custom "customRedirect.aspx" in the layouts section and implement code:
    • Lookup a special list in SharePoint "Landing Pages" using the "oldUrl" provided through the QueryString. The list contains a list of Landing Urls ("/newsletter") and the real URL ("www.mycompany.com/salesandmarketing/ebusiness/newsletters/english/signup.aspx") if you find a match, redirect the request to this page (use .NET Reflector how Microsoft does this). If you find no landing page redirect, I would redirect to a hidden publishing page on the root of your site that displays a fully branded 404-message.
    • Strong name the dll, create a feature and solutioni for deployment etc. For testing, it is enough to put the ASPX in the _layouts folder and the DLL in GAC.
  • Some thoughts
    • After reflecting a bit, I think it is only necessary to create one "Landing Pages Redirects" library at the root of your site. URLs tipically should be as short and "human readable" as possible.
    • With this approach, you have a very robust 404-handling implemented. Do you need additional logic? Just implement it in the already created ASPX-logic.

If I get to it, I'll implement this scenario and create an easy to deploy SharePoint solution out of it. I think this could be interesting to add as a feature to any internet site.

If you are interested in such a WSP solution download as well as the controls described in my posts "Building professional websites using MOSS 2007", basically custom MetaTags and PageTitles, please leave a comment.

Comments

 

Johnson said:

Why we can't use ** Url Mappings **. We solved redirection issues using Url Mapping in Web.config

Hope this helps!

July 12, 2007 10:35 AM
 

Nadeem said:

Johnson,

Michael's technique is very different than Url Mapping in web.config because it gives ordinary users the power to define their own mappings in a SharePoint list, without going through the dev shop.  You get all the CRUD, you can easily set up who has access to view and add URL mappings, you can  require approval on the URL mappings, set up alerts, version history, workflow, etc.

July 12, 2007 4:57 PM
 

Links (7/12/2007) « Steve Pietrek’s SharePoint Stuff said:

Pingback from  Links (7/12/2007) « Steve Pietrek’s SharePoint Stuff

July 12, 2007 7:40 PM
 

John H. Selnæs said:

Congratulations with your new job at Microsoft.

We will be very interested in a WSP solution for custom landing pages.

July 13, 2007 2:56 AM
 

Sharepoint 2007 link love 07-13-2007 at Virtual Generations said:

Pingback from  Sharepoint 2007 link love 07-13-2007 at  Virtual Generations

July 13, 2007 5:18 AM
 

Michael Greth said:

H, greeting from Berlin. I'm interested in the WSP solution as I plan to move my sharepointcommunity.de from DotNetNuk to SHarePint 2007 and need several easy to configure redirects

July 13, 2007 2:46 PM
 

Jereme Watts said:

I disagree with not being able to do redirects with an aspx page, here is the code that i have working when someone hits an unfriendly page. I'm also developing a best bets page that when he user get the 404 page not found it will use the search function to get some list of close bets for the strings used in the URL

<%@ Page Language="C#" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "www.w3.org/.../xhtml1-transitional.dtd">

<script runat="server">

   protected void Page_Load(object sender, EventArgs e)

   {Response.Redirect("https://

searchcentre.devsharepoint:10530/didyoumean.aspx"); }

</script>

<html xmlns="www.w3.org/.../xhtml" >

<head runat="server">

   <title>Untitled Page</title>

</head>

<body>

   <form id="form1" runat="server">

   <div>    

   </div>

   </form>

</body>

</html>

July 16, 2007 5:32 PM
 

Graham Shaw said:

Count me in for the WSP please.

August 6, 2007 4:27 PM
 

Nate Weber said:

Second in for the WSP as well!

Thanks.

August 16, 2007 4:06 PM
 

Blog del CIIN said:

Siguiendo con la tradicional recopilación periódica de recursos sobre WSS 3.0 &amp; MOSS, en esta ocasión

August 28, 2007 5:55 AM
 

Raymond Jensen said:

Count me in for the WSP please

September 28, 2007 4:01 AM
 

mhofer1976 said:

Hi all, A lot of you are asking me for the WSP. Unfortunately, my priorities have been set differently than expected and I'm mostly working on migrations at the moment and am rather busy these days.

If I can find the time, I'll do it in my spare time, sorry for announcing something I couln't come up with for 3 months now... I'll be more careful in the future.

September 28, 2007 8:58 AM
 

X said:

September 1, 2008 10:15 AM

Leave a Comment

(required )  
(optional )
(required )  
Add

About mhofer1976

For all of my IT carreer, I've been addicted to Microsoft-based software development, starting with VB, but then heading straight towards the .NET Framework in its earliest days. While working in different positions as a lead developer, project manager, pre-sales consultant and most recently a business unit manager, I've always kept beeing a developer and specialized on solutions in the Information Worker area, with an emphasis towards Enterprise Content Management. The Microsoft Office System and especially the SharePoint products and technologies are my favorite "playground", one big reason why I've joined the Microsoft Consulting Services in Switzerland where I'm currently working as Senior Consultant for Information Worker solutions.

Need SharePoint Training? Attend a SharePoint Bootcamp!

Posts (c) their respective authors. Everything else (c) 2007 SharePoint Experts