WordPress.org

Ready to get started?Download WordPress

Forums

The Wonderful World of MT Redirects (5 posts)

  1. stonegauge
    Member
    Posted 9 years ago #

    OK, I either am an idiot or am just missing something (meaning Readme.txt wasn't clear enough). I've already imported my MT entries and that went smooth.... I downloaded Alex King's MT Redirect script, configured the .php file and uploaded it.... Rebuilt my MT entries and....
    Google's still pointing to all my MT entries...
    I'm lost what to do now, to be honest. The Redirect script is saved in my root folder with the rest of my WP stuff. Should it have been saved somewhere else? Was I supposed to delete my MT entries from my server (having to rebuild my entries says otherwise).
    It should be a simple 1, 2, 3 thing and yet it's proving otherwise.

  2. Mark Jaquith
    WordPress Lead Dev
    Posted 9 years ago #

    Those other methods all differ based on your MT permalink setup. Try my method, which is independent:
    (Note, because your MT files are in html archives, you need mod_rewrite for this, so if you don't have that, stop reading)
    First step is to make your server parse html files for PHP. Add this to your site's .htaccess file

    AddType application/x-httpd-php .html

    Make this your MT individual entry template:

    <?php
    $wp_url = '<$MTEntryDate format="?year=%Y&monthnum=%m&day=%d&hour=%H&minute=%M&second=%S"$>';
    header("HTTP/1.1 301");
    header("Location: http://site.com/" . $wp_url);
    exit();
    ?>

    Rebuild your individual entries. This makes all your entries just contain this simple PHP 301 redirect that sends the browser to wordpress asking for an entry with the exact time (to the second) as the MT entry.
    Put this code in WordPress to fix the URI and complete the illusion. Put it near the top, after the wp-blog-header call, but BEFORE any content is echoed:

    /* Redirect Movable Type permalinks */
    if($year && $monthnum && $day && $hour && $minute && $second && $posts){
    foreach ($posts as $post) {
    $redirect_url = get_permalink();
    }
    header("HTTP/1.1 301");
    header("Location: $redirect_url");
    exit();
    }

    So here's the process: MT has generated a file with the exact time and date of the entry, with PHP code to ask WordPress for it. When the page is loaded, a 301 redirect sends it to wordpress with the date/time info. When WP sees that the time and date are specified down to the second, it realizes that there can reasonably only be one permalink for this entry. It gets the permalink that matches that time/date info, and does another 301 redirect, sending the user to the new entry.
    Google will eventually catch on, and your old URIs will disappear in the search engine.

  3. stonegauge
    Member
    Posted 9 years ago #

    I have archives in PHP AND HTML though. I had converted because the 301 mod said it'd be easiest with PHP archives to do the redirect...

  4. Anonymous
    Unregistered
    Posted 9 years ago #

    "Put this code in WordPress to fix the URI and complete the illusion. Put it near the top, after the wp-blog-header call, but BEFORE any content is echoed:
    /* Redirect Movable Type permalinks */
    if($year && $monthnum && $day && $hour && $minute && $second && $posts){
    foreach ($posts as $post) {
    $redirect_url = get_permalink();
    }
    header("HTTP/1.1 301");
    header("Location: $redirect_url");
    exit();
    } ""
    WHERE do I put it in WordPress?

  5. stonegauge
    Member
    Posted 9 years ago #

    Assuming you wanted that piece of code inserted into my index.php from wordpress:
    I'm getting this error now on individual entries:
    Parse error: parse error, unexpected T_STRING in /home/.kafka/username/stonegauge.com/archives/entrynumber.php on line 4

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.