Migrating from NON-DNN site to DNN website And keep old urls

Last post 07-13-2005 9:53 PM by captscott019. 27 replies.

Sort Posts:

  • Re: Migrating from NON-DNN site to DNN website And keep old urls

    03-03-2005, 6:31 AM
    The Inventua HrefExchanger allows you to do this, you just have to set your tab names to the old names of the pages.

    http://www.inventua.com/dnn-downloadshome.content
  • Re: Migrating from NON-DNN site to DNN website And keep old urls

    03-03-2005, 6:56 PM
    • Participant
      880 point Participant
    • jhenak
    • Member since 01-16-2004, 4:06 PM
    • Posts 176
    I'm still getting a 404 error.

    I suppose my question is no longer if it is possible but I'm curious about how The HTTPURL Rewrite module intercepts the request for a NON- ASP.net Page.

    If I request http://www.mysite.com/somePERLLink.pl

    IIS is configured to intercept that request with perl.exe and return the result. The same is true for .asp, .php, .aspx, etc. Each extension has with it a program that is used to interpet the server side page that is set within IIS.

    Does ASP.net Have access to redirect URLS that are not designated to be handled by ASP.Net?
  • Re: Migrating from NON-DNN site to DNN website And keep old urls

    03-03-2005, 7:24 PM
    • Star
      9,820 point Star
    • jbrinkman
    • Member since 06-18-2002, 6:28 PM
    • Posts 1,962
    • TrustedFriends-MVPs
    IIS will forward any request to the ISAPI associated with the extension. To make your current scenario work, just map .ASP to the ASP.Net dll and then the rewriter will work correctly. There is no reason to use another solution. The rewriter has all the power you need to handle this task, it is just a matter of configuration. There is no majic, all of the other solutions available work the exact same way.
    Joe Brinkman
  • Re: Migrating from NON-DNN site to DNN website And keep old urls

    03-03-2005, 8:06 PM
    • Member
      435 point Member
    • Sponge_Bob
    • Member since 01-05-2005, 10:52 AM
    • Hamilton ON
    • Posts 87

    I have created a module to aid in this view post 846367
    Free Community Forums Desktop Editor at BigByte Technologies Dnn 3x & 4x Modules @ dnn.bigbytetetech.ca
  • Re: Migrating from NON-DNN site to DNN website And keep old urls

    03-03-2005, 8:50 PM
    • Participant
      880 point Participant
    • jhenak
    • Member since 01-16-2004, 4:06 PM
    • Posts 176
    Thanks, That's what I thought.
  • Re: Migrating from NON-DNN site to DNN website And keep old urls

    03-04-2005, 8:11 AM
    • Participant
      1,585 point Participant
    • WEBPC
    • Member since 12-10-2004, 12:42 PM
    • Bedminster, NJ USA & Sydney, Australia
    • Posts 320
    Hi
    One other thing to think of is that you want search engine links to find the new pages and update thier DB to point to the new address. To do this you have to send a Response 301 "Moved Permanently"
    This also means that over a period of time you will not have to spend resources in just doing a redirect and will make the site faster (this does depend on how popular your site is).
    We are still on DNN2.1.2 and are using Slalom Services Custom 404 Handler primarily for the Response 301. Unfortunately they haven't got one for ver3
    Antony
  • Re: Migrating from NON-DNN site to DNN website And keep old urls

    03-04-2005, 11:34 AM
    • Participant
      880 point Participant
    • jhenak
    • Member since 01-16-2004, 4:06 PM
    • Posts 176
    Hmm, if they look for the page at the old URL and it returns the same information (By USing the URL Rewrite DNN Module) Why do I need a 301 re-direct?
  • Re: Migrating from NON-DNN site to DNN website And keep old urls

    03-04-2005, 12:28 PM
    • Participant
      1,585 point Participant
    • WEBPC
    • Member since 12-10-2004, 12:42 PM
    • Bedminster, NJ USA & Sydney, Australia
    • Posts 320
    Just from the points of reducing the load on the server in having to rewrite the URL's and updating the search engines records so new visitors go direct to the new page.
    Also down the track what if you change the site again you will have more admin to make more changes and things would get more complicated.
    Antony
  • Re: Migrating from NON-DNN site to DNN website And keep old urls

    03-04-2005, 3:32 PM
    • Participant
      1,375 point Participant
    • rickhodder
    • Member since 04-04-2003, 2:12 AM
    • Posts 276
    Just a question here: with the rewrite/redirect solution, the only rewrite/redirect will probably only be the first entry into the portal for a user, right? I would assume that once they are in the portal, anywhere they go to within the portal will be using the tabid stuff without redirection, right?

    Ex.

    I point my browser at myoldpage.aspx
    I get redirected to default.aspx?tabid=xxx
    Once there, any links on the page will already be in the format default.aspx?tabid=yyy

    Am i right?
  • Re: Migrating from NON-DNN site to DNN website And keep old urls

    03-04-2005, 4:34 PM
    • Participant
      880 point Participant
    • jhenak
    • Member since 01-16-2004, 4:06 PM
    • Posts 176
    With Friendly URLS it is always re-written. Thus load on the server is the same, and when the user is re-directed the new URL should be passed to the client/spider. Since the re-direct's are stored in the site.config it makes the solution portable. Also since I am the server admin it makes the process easy.

    If DNN meets our needs it will be here to stay for awhile :)
  • Re: Migrating from NON-DNN site to DNN website And keep old urls

    03-04-2005, 4:41 PM
    • Participant
      1,585 point Participant
    • WEBPC
    • Member since 12-10-2004, 12:42 PM
    • Bedminster, NJ USA & Sydney, Australia
    • Posts 320
    You are right that once someone has reached your site and clicks on links shown on the pages then they will be following those links as coded in the HTML transferred to thier browser.

    I am not sure on this but in most cases if there is a rewrite function for friendly URLs etc every html request is going to involve the rewrite function to either decipher a friendly URL or encode a friendly one. The same will happen with a redirect however after a period you will be able to do away with the redirect as people enter the site by the new URLs.

  • Cool [cool] Re: Migrating from NON-DNN site to DNN website And keep old urls

    04-10-2005, 5:17 PM
    • Member
      50 point Member
    • dotnetoholic
    • Member since 06-24-2002, 3:34 PM
    • Los Angeles
    • Posts 10

    I just set up my site to redirect old htm and aspx pages to the new DNN URLs and to send a Response 301 "Moved Permanently" for the benefit of search engine robots. I did not notice the SiteUrls.config file until I was done, but it probably would not have sent the 301 code anyway. Here is how I did it:

    1. Set the custom error page for 404 errors in IIS to my custom ErrorRedirect.aspx page. My site is hosted on webhost4life, and they provided a control panel form to set this value. This step is necessary to handle non-ASP.NET pages, such as .htm and .asp, which are not affected by the web.config setting below.

    2. To redirect old .aspx pages, I added an error element to web.config to redirect 404 errors to my custom ErrorRedirect.aspx page:

    <
    customErrors mode="RemoteOnly">
    <error statusCode="404" redirect="/ErrorRedirect.aspx" />
    </customErrors>

    3. I wrote the ErrorRedirect.aspx page shown below and deployed it to the root folder. If you use this page, replace yourwebsitename.com with your actual site name, correct the tab numbers and e-mail address as needed, and modify the SELECT CASE statement to include the redirects you desire.

    <PRE><%@ Language="vb" %>
    <HTML>
       <script runat="server" language="vb">
      
      ' This sub redirects from old files to new files at new locations
      ' or with a new URL.
            Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

       Try
        Dim strRedirectUrl As String
        Dim strRawUrl As String = Request.RawUrl
        ' Example RawUrl:
        ' /errorredirect.aspx?404;http://www.yourwebsitename.com:80/index.htm
        ' /ErrorRedirect.aspx?aspxerrorpath=/Useful_Sites.aspx
        Trace.Write("ErrorRedirect.Page_Load", String.Format("RawUrl = {0}", strRawUrl))
        Dim strSourceUrl As String = Request.QueryString("aspxerrorpath")
        If strSourceUrl Is Nothing OrElse strSourceUrl.Length = 0 Then
         If strRawUrl.IndexOf("?404") > 0 Then
          strSourceUrl = strRawUrl.Substring(strRawUrl.LastIndexOf("/"))
         ' Else leave strSourceUrl empty.
         End If
        End If
        Trace.Write("ErrorRedirect.Page_Load", String.Format("strSourceUrl = {0}", strSourceUrl))
        Select Case strSourceUrl.ToLower()
        Case "/useful_sites.aspx"
         strRedirectUrl = "http://www.yourwebsitename.com/UsefulSites/tabid/52/Default.aspx"
        Case "/index.htm", "/index.html", "/default.htm", "/default.html", "/default.asp"
         strRedirectUrl = "http://www.yourwebsitename.com/"
        Case Else
         strRedirectUrl = String.Empty
        End Select
        If strRedirectUrl.Length > 0 Then
         Response.Status = "301 Moved Permanently"
         Response.AddHeader("Location", strRedirectUrl)
         Response.End
        End if
       Catch ex As Exception
        Trace.Warn("ErrorRedirect.Page_Load", ex.ToString())
        ' Show this error page.
        'Response.Redirect("http://www.yourwebsitename.com/")
       End Try
            End Sub

      Private Sub Send_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
       System.Web.Mail.SmtpMail.Send(txtEmail.Text, "support@yourwebsitename.com", "yourwebsitename.com: 404 - Page Not Found", txtDescription.Text)
       lblFeedback.Visible = False
       lblResult.Text = "E-mail has been sent. Thank you."
      End Sub
       </script>
    <head>
      <title>404 - Page Not Found</title>
      <meta name="robots" content="noindex" />
    </head>
    <body>

    <h1>404 - Page Not Found</h1>

    Sorry but the page you were looking for has not been found.  We tried our best to direct you
    to a suitable place automatically but we did not find a suitable match...

    <h3>What can you do now?</h3>
    Well you could try <a href="JAVASCRIPT:window.history.back();">going back</a> to the last page
    you visited and then browsing somewhere else, alternatively you could visit our <a href="/">front page</a>
    and try browsing your way down from there - whatever you're looking for should be available either
    directly from the front page or from one of the sections which are linked from the front page.

    <h3>If all else fails...</h3>
    If you think that the link you just followed really should work and you've tried quite hard to
    access it then drop us an e-mail explaining which link keeps bringing you to this page and where you
    found it.  Most of the time these sorts of problems are automatically registered somewhere and somebody
    will be dealing with it, but on the off-chance that for some reason this process has failed if you
    drop us an e-mail somebody will look into it.

        <form runat="server">
        <p>
        <asp:Label id="lblFeedback" runat="server">
        Please describe what the error was to the administrators so this can get fixed:
        <table>
        <tr><td>Email:</td><td><asp:TextBox id="txtEmail" runat="server"/></td></tr>
        <tr><td colspan=2>Description:<br /><asp:TextBox id="txtDescription" TextMode="multiline" height=200 width=400 runat="server"/></td></tr>
        </table>
        <asp:Button id="btnSend" onclick="Send_Click" Text="Send" runat="server"/>
        </asp:Label>
        <asp:Label id="lblResult" runat="server" />
        </p>
        </form>
    </body>
    </HTML>
    </PRE>

  • Re: Migrating from NON-DNN site to DNN website And keep old urls

    07-13-2005, 9:53 PM
    • Member
      125 point Member
    • captscott019
    • Member since 11-25-2003, 3:18 PM
    • Pennsylvania
    • Posts 25
    dotnetoholic,

    Thank you very much for this very useful code. I'd been struggling for days trying to 301 redirect .aspx pages in DNN. I was using Inventua's HREF exchanger in DNN2, and am in the process of upgrading to DNN3 and wanted to take advantage of the friendly URL's. I was affraid of taking a big hit in the search engines until I found your code.

    One question,
    Can you use "Regular Expressions" (regex) in the errorredirect.aspx page? I have several hundred pages to redirect and regex would make it alot simpler.

    Thanks,
    Scott Jennings
    Scott Jennings

    MarinaPal.com
Page 2 of 2 (28 items) < Previous 1 2