schussman.com logo

Backend: Redirect Movabletype requests to Textpattern

I’ve put together a short and very, very ugly php script to match names of my Movabletype entries with their Textpattern counterparts (thanks again to Pix for his conversion script).

The script matches entry titles and then generates a list of redirect statements that can be put in a .htaccess file. Any subsequent request for your old Movabletype entries will be redirected to the appropriate Textpattern location. The script only works, however, with Movabletype archives of the form ”/archives/000001.html”; this script won’t do you any good if your entries are archived with names like ”/archives/Hey-This-Is-Fancy.html”. If there’s any interest, I’ll see what I can do to re-map those dirified URLs.

Does it work? Well, it seems to have worked for me. The script provides a workable solution to the problem of having search engines or other external sites point to your old Movabletype entries, and it redirects links from within your own entries (something similar to this functionality is on Pix’s to-do list; it’s nice to know that I don’t have Textpattern entries pointing to old-school MT entries).

Will it work for you? Geeze, I don’t have the slightest idea.

Note: Duplicates. The script highlights, but doesn’t attempt to correct, any duplicates that it identifies. These occur any time you have more than one match for any given title. In my case, I had lots of entries with the title “Quickies” or “Friday.” Obviously, you can’t have the same entry redirected to more than one address, so you’ll have to track down and get rid of the duplicates. Look for lines with “Dupe” appended to them, and note that the line immediately above that line is part of the duplicate set.

Don’t laugh at my code. I learned it from watching Dateline specials about computer hackers.

tpredir.php is here

  1. The only suggestion I would make is to add the 302 status code in your redirect—otherwise it is only flagged as a temporary change and the search engines won’t pick up the new one/delete the old one properly. As I understand it anyway, not being a programmer either :) —fncll
    Chris L    Mar 16, 02:03 PM    #
  2. Thanks for the suggestion, Chris. I hadn’t thought of that. I revised the code to set the redirect to permanent.
    Alan    Mar 16, 04:12 PM    #
  3. Does this still work for longer directory trees? For example, /archives/indiv/blogging/000299.html.
    Adam    May 3, 12:45 PM    #
  4. As long as 1) the filename is numeric, and 2) the path is static, then the script should be able to handle it with just a revision to the path.
    Alan    May 3, 05:30 PM    #
  5. I tried to download the script, but all I got was a page that said, “Engaging tractor beam. ” :) What’s the correct link to download this excellent script? Thanks in advance,
    Vik    May 16, 04:16 AM    #
  6. Vik, that’s a strange happening. You should be able to download the script right here. Can you save-as that link?
    Alan    May 17, 04:49 AM    #
  7. That worked. Thanks Alan!
    Vik    May 17, 12:01 PM    #
  8. This worked like a charm to me and is so helpful. Thanks a lot for writing it!
    Phil    Jun 19, 04:00 AM    #
Name
E-mail (will be spam-armored)
http://
Message
  Textile Help

Backend: Redirect Movabletype requests to Textpattern

I’ve put together a short and very, very ugly php script to match names of my Movabletype entries with their Textpattern counterparts (thanks again to Pix for his conversion script).

The script matches entry titles and then generates a list of redirect statements that can be put in a .htaccess file. Any subsequent request for your old Movabletype entries will be redirected to the appropriate Textpattern location. The script only works, however, with Movabletype archives of the form ”/archives/000001.html”; this script won’t do you any good if your entries are archived with names like ”/archives/Hey-This-Is-Fancy.html”. If there’s any interest, I’ll see what I can do to re-map those dirified URLs.

Does it work? Well, it seems to have worked for me. The script provides a workable solution to the problem of having search engines or other external sites point to your old Movabletype entries, and it redirects links from within your own entries (something similar to this functionality is on Pix’s to-do list; it’s nice to know that I don’t have Textpattern entries pointing to old-school MT entries).

Will it work for you? Geeze, I don’t have the slightest idea.

Note: Duplicates. The script highlights, but doesn’t attempt to correct, any duplicates that it identifies. These occur any time you have more than one match for any given title. In my case, I had lots of entries with the title “Quickies” or “Friday.” Obviously, you can’t have the same entry redirected to more than one address, so you’ll have to track down and get rid of the duplicates. Look for lines with “Dupe” appended to them, and note that the line immediately above that line is part of the duplicate set.

Don’t laugh at my code. I learned it from watching Dateline specials about computer hackers.

tpredir.php is here

  1. The only suggestion I would make is to add the 302 status code in your redirect—otherwise it is only flagged as a temporary change and the search engines won’t pick up the new one/delete the old one properly. As I understand it anyway, not being a programmer either :) —fncll
    Chris L    Mar 16, 02:03 PM    #
  2. Thanks for the suggestion, Chris. I hadn’t thought of that. I revised the code to set the redirect to permanent.
    Alan    Mar 16, 04:12 PM    #
  3. Does this still work for longer directory trees? For example, /archives/indiv/blogging/000299.html.
    Adam    May 3, 12:45 PM    #
  4. As long as 1) the filename is numeric, and 2) the path is static, then the script should be able to handle it with just a revision to the path.
    Alan    May 3, 05:30 PM    #
  5. I tried to download the script, but all I got was a page that said, “Engaging tractor beam. ” :) What’s the correct link to download this excellent script? Thanks in advance,
    Vik    May 16, 04:16 AM    #
  6. Vik, that’s a strange happening. You should be able to download the script right here. Can you save-as that link?
    Alan    May 17, 04:49 AM    #
  7. That worked. Thanks Alan!
    Vik    May 17, 12:01 PM    #
  8. This worked like a charm to me and is so helpful. Thanks a lot for writing it!
    Phil    Jun 19, 04:00 AM    #
Name
E-mail (will be spam-armored)
http://
Message
  Textile Help