Redirecting from old static .htm site to new .aspx site

Rate It (1)

Last post 04-29-2008 8:44 AM by rootsilver. 5 replies.

Sort Posts:

  • Redirecting from old static .htm site to new .aspx site

    09-01-2007, 5:22 PM

    I've Google a fair bit about this, but I'm still confused. I have a static site built with html that I am migrating to ASP.NET 2.0.  However, I don't want links to break, and need to redirect from all the old pages to the new ones. As the new ones will be generated dynamically, the urls will change a lot: it won't simply be a case of the the url changing from .htm to .aspx.

    I've heard that using the metatag of the .htm page is dangerous with regards to search engine crawlers. What is the best way of having this redirect happen? Is it just going through and putting a manual link on all the old .htm pages? Or is there an automatic way?

     TIA

  • Re: Redirecting from old static .htm site to new .aspx site

    09-01-2007, 7:01 PM
    Answer
    • All-Star
      97,749 point All-Star
    • mbanavige
    • Member since 11-06-2003, 1:29 PM
    • New England, USA
    • Posts 10,323
    • Moderator
      TrustedFriends-MVPs

    you ultimate answer may depend on how many pages you need to redirect.

    One technique could be to:

    1. create a mapping list from the old page to new page (database or XML ?)
    2. Map the htm extension to the aspnet_isapi.dll just like .aspx pages are so you can "see" htm requests
    3. create an httpmodule to intercept all page requests (including .htm requests)
    4. httpmodule looks up the page that was requested to see if it's in the "map"
    5. if it's in the "map" the httpmodule issues a redirect to the new location

     

    Mike Banavige
    ~~~~~~~~~~~~
    Need a site code sample in a different language? Try converting it with: http://converter.telerik.com/
  • Re: Redirecting from old static .htm site to new .aspx site

    09-01-2007, 8:28 PM
    Answer
    • Member
      284 point Member
    • rootsilver
    • Member since 08-21-2007, 5:08 PM
    • NYC
    • Posts 52

    Hi CoriolisForce

    I've run into this a couple times before as well, so I sat down and wrote you a very detailed response, because if you start trying to figure out how and why you
    might need to write code for a CustomConfigHandler, you'll spend a lot of time wondering why something so simple should be so complicated, when you really can do it very easily.

    You can find the full write up and sample code here:

    http://www.rootsilver.com/2007/09/how-to-support-old-links-and-r.html

    You should be good to go, and have this up and running very quickly; let me know if you have any problems.

     -Jeff
     

    Jeffrey Knight | MCTS .NET 2.0 | RHCT | http://www.rootsilver.com
  • Re: Redirecting from old static .htm site to new .aspx site

    09-02-2007, 4:43 AM

    Wow, Jeff, thanks for that huge effort! It's much appreciated! I'll let you know if I strike any snags with it. It's the next phase of my development, so it'll probably be a few days before I do it.

    Thanks to mbanavige too!

  • Re: Redirecting from old static .htm site to new .aspx site

    04-25-2008, 4:47 PM
    • Member
      2 point Member
    • ashipp
    • Member since 04-25-2008, 8:46 PM
    • Valparaiso
    • Posts 1

    I was wondering exactly where to put the <legacyredirects>?  I have tried about every spot in the web.config file and when I compile it gives me errors.

     

    Never mind, we figured it out at the end of the day on Friday.

  • Re: Redirecting from old static .htm site to new .aspx site

    04-29-2008, 8:44 AM
    • Member
      284 point Member
    • rootsilver
    • Member since 08-21-2007, 5:08 PM
    • NYC
    • Posts 52
    It's all in the .zip file at the end of my post here
    Jeffrey Knight | MCTS .NET 2.0 | RHCT | http://www.rootsilver.com
Page 1 of 1 (6 items)