WordPress.org

Ready to get started?Download WordPress

Forums

blogger importer, redirect old url names? (4 posts)

  1. jwbond
    Member
    Posted 8 years ago #

    I used Andy's blogger importer, which worked great!

    However, I do not want to delete the old url names of many of my old posts. I want it to redirect to the new version of the page.

    Anyone know how to do this?

  2. IsaacSchlueter
    Member
    Posted 8 years ago #

    What were your old URIs like? If you can come up with a rule for translating the URIs, then I or someone else here can surely tell you what to put in your .htaccess file to make it happen.

  3. sok
    Member
    Posted 8 years ago #

    Not sure if this is the right thread to post in but I think I have a similar problem. I moved from blogger to wordpress fairly easily and wanted to add redirects from my old Blogger pages to the new WordPress ones to ensure the info could still be found.

    However, I don't have individual html pages for my posts archived on Blogger. More like one long page with anchors to posts - for example http://mywebsite/.../2005_11_01_blogarchive.html#113086462116806676

    That same post has an individual link on wordpress.

    How do I redirect from an html anchor?

  4. IsaacSchlueter
    Member
    Posted 8 years ago #

    The tricky thing about that is that the hash (the part of the url after the #) isn't sent to the server, AFAIK.

    However, you can get this client-side through location.hash. This technique could work for you.

    DISCLAIMER: Not tested, so it might need fixing. I stand by the concept, though.

    1. Create a file called blogger_redirector.html.
    2. In that file, put this:

    <html><head><title>just a redirecter</title>
    <script type="text/javascript">
    // fill in with your info
    var prefix = 'http://mywebsite/.../';
    // the long tedious part...
    var a = new Array();
    // fill in the following lines appropriately.
    // this will be long and boring. I'm not sure if there's any
    // place in WordPress where it stored the blogger key,
    // or else you could maybe generate this automagically.
    // a[blogger key] = wordpress id;
    a[11308646211680666] = 1;
    a[18470128712861927] = 2;
    a[12897918734298716] = 3;
    // ...
    a[20098781672308612] = 500;
    var h=location.hash;
    var done=false;
    if(h)
    {
    if(a) {
    if(a[h]) {
    done = true;
    location.replace(prefix + '?p=' + a[h]);
    }
    }
    }
    if(!done)window.location.replace(prefix);
    </script>
    </head>
    <body>
    You got here somehow. That's odd. <a href="index.php">How about you go here instead?</a>

    </body></html>

    3. Then, in your .htaccess file, outside the WordPress section, add this rule:

    RewriteRule ^[0-9]{4}_[0-9]{2}_[0-9]{2}_blogarchive.html /blogger_redirector.html [NC,L]

    The way it works is this: the client requests a page, and your server gives him the redirector page instead. Then, it looks at the hash portion of the URL, and redirects client-side appropriately.

    The downside is that it won't work if the client doesn't have javascript enabled, but since you really can't do this server-side, it's the only way that I can think of.

    --i

Topic Closed

This topic has been closed to new replies.

About this Topic