How To: Redirecting in Community Server 2007

Jun 18, 2007 04:23 · 408 words · 2 minutes read communityserver

When I updated this site to CS2007, some of the pages broke. The two problems came up due to older configurations of this site. First, in a very old config, I had my RSS feed at /RSS/default.aspx. The other problem came about because I used to have the blog page at the root and now I have gone back to the default way of doing things. So let me show you how I solved both issues.

First the part about redirecting RSS/default.aspx. Actually this has nothing to do with Community Server. I simply went to my hosting provider’s control panel site and created a virtual directory that pointed to the RSS feed, which is now hosted at Feedburner.

OK, that was easy. Redirecting the requests to blog pages at the root to now go to /blogs/technovangelist was a bit tougher. There were actually two main problems here: How do I redirect rss.aspx in the root of the site, and how do I redirect all of the calls to the archive blog postings that were under /archive to /blogs/technovangelist/archive.

The first of those two happened to be fairly easy. I simply created an rss.aspx page in the root with the following content:

<script runat="server">
private void Page_Load(object sender, System.EventArgs e)
{
Response.StatusCode = 301;
Response.Status = "301 Moved Permanently";
Response.RedirectLocation="http://feeds.feedburner.com/Technovangelist";
Response.End();
}

 

Actually, it was a bit simpler than that. The actual process was search the net to find Hansleman’s entry on solving the problem.

 

To solve the problem with the archive pages I got to take advantage of the new SiteUrls_Override.config file. Here is my config file with some of the non relevant lines removed:

xml version="1.0" encoding="utf-8" ?>
<Overrides>
<Override xpath="/SiteUrls/locations" mode="add">
<location name="OldBlogPathRedirect" themeDir="blogs" path="/"
type="CommunityServer.Blogs.Components.BlogLocation, CommunityServer.Blogs" >
<url name = "Oldweblogday"
path="/blogs/technovangelist/archive/{1}/{2}/{3}.aspx"
pattern="archive/(d{4})/(d{1,2})/(d{1,2}).aspx"
physicalPath="##blogthemeDir##"
vanity="{2}?App=${{app}}&y=$1&m=$2&d=$3" page="postlist.aspx" />
<url name = "Oldweblogmonth"
path="/blogs/technovangelist/archive/{1}/{2}.aspx"
pattern="archive/(d{4})/(d{1,2}).aspx"
physicalPath="##blogthemeDir##"
vanity="{2}?App=${{app}}&y=$1&m=$2&d=1" page="postlist.aspx" />
<url name = "OldweblogpostId"
path="/blogs/technovangelist/archive/{1}/{2}/{3}/{4}.aspx"
pattern="archive/(d{4})/(d{1,2})/(d{1,2})/(d+).aspx"
physicalPath="##blogthemeDir##"
vanity="{2}?App=${{app}}&y=$1&m=$2&d=$3&PostID=$4"
page="post.aspx" />
<url name = "OldweblogpostName"
path="/blogs/technovangelist/archive/{1}/{2}/{3}/{4}.aspx"
pattern="archive/(d{4})/(d{1,2})/(d{1,2})/([a-zA-Z0-9-._]*?).aspx"
physicalPath="##blogthemeDir##"
vanity="{2}?App=Technovangelist&y=$1&m=$2&d=$3&PostName=$4"
page="post.aspx" />
<url name = "Oldweblogpostcategory"
path="/blogs/technovangelist/archive/category/{1}.aspx"
pattern="archive/category/(d+).aspx"
physicalPath="##blogthemeDir##"
vanity="{2}?App=${{app}}&CT=BlogPost&CategoryID=$1"
page="postlist.aspx" />
<url name = "Oldweblogarticlecategory"
path="/blogs/technovangelist/articles/category/{1}.aspx"
pattern="articles/category/(d+).aspx"
physicalPath="##blogthemeDir##"
vanity="{2}?App=${{app}}&CT=BlogArticle&CategoryID=$1"
page="postlist.aspx" />
</location>
</Override>
</Overrides>

As you you may be able to see, I just copied the lines from the SiteUrls.config file, then modified a few of the values. I am sure there is a more elegant way to do it, but this worked. If you know of a better way to handle this, please let me know.