Community Server & Redirect of old urls

We’ve been running on .Text for quite a while, but continue to find bugs in it. Especially the fact that randomly, people cannot edit the items they have just placed on their blog is an annoying one.

We are hoping to solve a lot of problems by upgrading to Community Server from Telligent Systems. The reason why we haven’t upgraded in the past, is because of the new location of the pages. Version 1.1 has become more flexible on the location of the community site and I’ve found a very small but excellent component for url rewriting. I’ve done some of the coding myself at first, but with this component I don’t have to reinvent the wheel as it has all functionality I want.

Via Mischa Kroon I’ve found the link to this url rewriting component. It reads settings from your web.config to see what page(s) it has to redirect and whereto. This is very flexible as it also works with regular expressions. For all Community Server junkies or people that are afraid to upgrade (like I was), here’s what I did.

Remember, these instructions are for CS 1.1 but should work anywhere.
I’ll first explain the current and new situations. In the current situation, the url is like whereas the new situation will be There are a lot of possible directories and files behind those urls, so it should definitly be solved by a regular expression. Here’s how I did it.

First, download the component, unzip it and in the directory /demo/bin/ you can find two .dll files. Copy those to the /bin/ directory on your website.
Now you have to edit your web.config and you are done! First, find the <httpmodules> tag. If you haven’t added anything, make it look like this.

   1:  <httpModules>
   2:      <add name="RedirectModule" type="Madgeek.Web.RedirectModule, Madgeek.RedirectModule" />
   3:      <add name="CommunityServer" type="CommunityServer.CSHttpModule, CommunityServer.Components" />
   4:      <add name="Profile" type="Microsoft.ScalableHosting.Profile.ProfileModule, MemberRole (...) 7562"/>
   5:      <add name="RoleManager" type="Microsoft.ScalableHosting.Security.RoleManagerModule, M (...) 7562" />
   6:  </httpModules>

At line 2 you can see the line I added. I’ve truncated some of the content (in line 4 and 5) so it won’t be that long.
Now you add another line to your configSections.

   1:  <configSections>
   2:      <sectionGroup name="memberrolesprototype">        
   3:          <section name="membership" type="Microsoft.ScalableH (...) 7562"/>
   4:          <section name="roleManager" type="Microsoft.ScalablH (...) 7562"/>
   5:          <section name="profile" type="Microsoft.ScalableHost (...) 7562"/>
   6:          <section name="anonymousIdentification" type="Micros (...) 7562"/>            
   7:      </sectionGroup>
   8:      <section name="redirections" type="Madgeek.Configuration.XmlSerializerSectionHandler, Madgeek.RedirectModule" />
   9:  </configSections>

This time you can see the added section at line 8.

Now all you have to do is add your redirection part. Mine looks like this:

   1:  <redirections type="Madgeek.Web.ConfigRedirections, Madgeek.RedirectModule">
   2:      <add permanent="true" ignoreCase="true" targetUrl="^/MainFeed.aspx" destinationUrl="/blogs/MainFeed.aspx" />
   3:      <add permanent="true" ignoreCase="true" targetUrl="^/(dennis|rj|patrick)/(.*).aspx??(.*)" destinationUrl="~/blogs/$1/$2.aspx" />
   4:  </redirections>

In line two the main rss feed is redirected to the new location. This only concerns one file and is, as it looks, very easy. But now the current blogs to their new location. The third line tells that it should look for directories starting with either dennis, rj, or patrick and forward those to the destination url. I will have to include all bloggers currently in our community in the final version though. The regex will place the found user-directory at the $1 location and the complete directory structure after that and the file behind it at the $2 location. It should forward every .aspx file.

You can also see the parameter permanent which is set to true. This will make the component send an error 303. This tells the search engines like Google that it’s a permanent move of the file. The search engine will then update its index, which was very important for us.

I’ll do some additional tests soon and hope to be able to upgrade BloggingAbout.NET without any problems.

You may also like...

5 Responses

  1. Ramon Smits says:

    Wanneer heb je het af… over een uurtje ;-). Hopelijk is het snel gefixed dan kan ik eindelijk eens wat gaan bijdragen.

  2. Goed gedaan Dennis!!!!

  3. Just wondering. Do we, as bloggers need to do anything after the server has been upgraded?

  4. I wrote a similar utility, though as an httpHandler that you can plug into .Text:

  5. I received 1 st loan when I was 25 and that supported me a lot. But, I require the collateral loan also.

Leave a Reply

Your email address will not be published. Required fields are marked *