Topic: Blog Business

Hey, my blog’s eyes are up here, pal!

Yes, it’s CSS naked day! Actually, it’s CSS naked 48 hours so that it overlaps with every timezone.

Anyway, it’s a little thing to promote web standards or some such hoo-ha, and it sounded like fun. So TBOTCOTW will look like 1996 for the next couple of days.

Popularity: 23% [?]

Movable Type to WordPress without losing your permalinks

So you’d like to upgrade to WordPress from Movable Type? It’s not very hard… if you’ve always had the same permalink structure. But if you’ve gone through the MovableType versions from 1.5 to 2.x to 3.x and finally to 4.1 (like me) then you’ve probably been through a couple of URL scheme revisions.

In my case, I started out with Movable Type’s default (and, at the time, only) permalink structure… post ID (a six digit number) followed by .html in the archives directory to avoid cluttering up the top one. It looked like this: “http://tbotcotw.com/archives/000334.html.” Of course, from there I switched to .shtml, then quickly to .php, and when MT finally supported it, permalinks based on the post name (all the words with underscores replacing the whitespace). At around the same time I read Mark Pilgrim’s excellent post on cruft-free and future-proof URLs in Movable Type. I’d finally found a URL structure that (I thought, it turns out that the underscore was a bad idea) would stand the test of time: post name with underscores for whitespace and no extension.

This was exasperating, though, since switching to a new URL scheme in midstream meant that my permalinks were now not very perma. I was getting lots of 404s because people had linked to a URL that didn’t exist anymore. And that was hurting my Google page rank. I considered fixing the problem by publishing a page with a php location header that would redirect from the old URL to the new seamlessly (using a 301 error code). But actually building those pages statically slowed down the already miserably slow interface to MT (my server is a piece of crap)… comments would take over a minute to be published when two or three individual entries and two category archives had to be built. So I had to wait until MT caught up and allowed dynamic publication, then I created a new archive mapping for the old URL structure and MT would automatically serve a page with the location header whenever a browser requested an old page. Pretty hacky, but it worked very well.

Fast forward to today and I still get hits on old posts from links that someone wrote in 2002. I wanted to duplicate my redirect scheme after I switched blogging systems but neither the MT export nor the WP import pays any attention to post ID, so I hacked both of them as I mentioned here. I had to use an old (2.1?) version of the import script in WordPress, but it worked just fine. Then I built a series of mod_rewrite rules to redirect from every one of the many URL structures I’ve ever used:

# Convert old archives
RewriteRule ^/archives/([0-9]*)\.php$ /$1/ [R=301,L]
RewriteRule ^/archives/([0-9]*)\.html$ /$1/ [R=301,L]
RewriteRule ^/archives/([0-9]*)\.shtml$ /$1/ [R=301,L]
RewriteRule ^/archives/([0-9][0-9][0-9][0-9]/[0-9][0-9]/.*)\.php$ /$1/ [R=301,L]
RewriteRule ^/archives/old/([0-9]*)\.php$ /$1/ [R=301,L]
RewriteRule ^/archives/cat_(.+)\.php$ /category/$1/ [R=301,L]
RewriteRule ^/archives/cat_(.+)\.html$ /category/$1/ [R=301,L]
RewriteRule ^/archives/cat_(.+)\.shtml$ /category/$1/ [R=301,L]
RewriteRule ^/archives/?$ /archive/ [R=301,L]
RewriteCond %{REQUEST_URI} !^/archives/[0-9][0-9][0-9][0-9]/[0-9][0-9]/?.*$ [NC]
RewriteCond %{REQUEST_URI} !^/archives/[0-9][0-9][0-9][0-9][0-9][0-9]\.?.*$ [NC]
RewriteCond %{REQUEST_URI} !^/archives/tag/.*$ [NC]
RewriteCond %{REQUEST_URI} !^/archives/author/.*$ [NC]
RewriteRule ^/archives/(.*)$ /category/$1 [R=301,L]
RewriteRule ^/archives/(.*)$ /$1 [R=301,L]

This converts the old “/archives/000334.html” format to “/000334/,” changes “/archives/cat_blog_business.html” (another legacy MT convention) to “/category/blog_business/,” and removes the “/archives/” from every other URL. At this point the numeric requests are handled by a plugin called Permalink Redirect. Just put “%post_id%/” in the old permalink structure field and blamo… no more 404s, everybody who clicks an ancient link is sent to the correct post.

The next problem was the MT underscores to WP hyphens issue. It’s actually a good idea to use hyphens… Google doesn’t recognize underscores as whitespace (yet), so you’re destroying a source of relevant keywords if your URL is a big_string_like_this. On the other hand, big-string-like-this then gets your page in the index with those four keywords, raising your page rank. I quickly found that, in most circumstances, WordPress automatically converts underscores to hyphens. Only when the URL has something after the title, like in “/2008/04/big_string_like_this/feed/,” or if a category is involved, does WordPress fail to convert. Perhaps I should take the time to fix that in the code… until then, I’ll use these mod_rewrites:

# Change underscores hyphens
RewriteRule ^/category/([^_]*)_([^_]*)_([^_]*)_(.*)$ /category/$1-$2-$3-$4/ [R=301,L]
RewriteRule ^/category/([^_]*)_([^_]*)_(.*)$ /category/$1-$2-$3/ [R=301,L]
RewriteRule ^/category/([^_]*)_(.*)$ /category/$1-$2/ [R=301,L]
RewriteRule ^/([0-9][0-9][0-9][0-9]/[0-9][0-9])/([^_/]*)_([^_/]*)_([^_/]*)_(.*)/(.+)$ /$1/$2-$3-$4-$5/$6 [R=301,L]
RewriteRule ^/([0-9][0-9][0-9][0-9]/[0-9][0-9])/([^_/]*)_([^_/]*)_(.*)/(.+)$ /$1/$2-$3-$4/$5 [R=301,L]
RewriteRule ^/([0-9][0-9][0-9][0-9]/[0-9][0-9])/([^_/]*)_(.*)/(.+)$ /$1/$2-$3/$4 [R=301,L]

This will ignore the underscores (and let WordPress handle them) unless it’s a category or there are characters after that last slash. Finally, I had to move all my syndication feeds to the new structure:

# Change to wordpress feeds
RewriteRule ^/atom$ /wp-atom.php [R=301,L]
RewriteRule ^/atom\.xml$ /wp-atom.php [R=301,L]
RewriteRule ^/index\.atom$ /wp-atom.php [R=301,L]
RewriteRule ^/index\.rdf$ /wp-rdf.php [R=301,L]
RewriteRule ^/index\.xml$ /wp-rss2.php [R=301,L]
RewriteRule ^/rss\.xml$ /wp-rss.php [R=301,L]
RewriteRule ^/([0-9][0-9][0-9][0-9]/[0-9][0-9]/.*)\.atom$ /$1/feed/ [R=301,L]
RewriteRule ^/([0-9][0-9][0-9][0-9]/[0-9][0-9]/.*)\.atom/$ /$1/feed/ [R=301,L]
RewriteRule ^/([0-9][0-9][0-9][0-9]/[0-9][0-9]/.*)\.xml$ /$1/feed/ [R=301,L]
RewriteRule ^/([0-9][0-9][0-9][0-9]/[0-9][0-9]/.*)\.xml/$ /$1/feed/ [R=301,L]

Nothing complicated there.

Then I found one more problem. Movable Type makes sure that permalink slugs are globally unique, and posts with the same titles get tagged with “-1,” “-2,” etc. WordPress doesn’t care if they’re globally unique, as long as they’re not in the same month. So I had to watch my logs for 404s, then go back and rename the posts. At this point the Redirection plugin was invaluable. It automatically builds a 301 redirect from old name to new when you retitle a post… so I could change all those post names back to the Movable Type default without worrying about blocking new links that pointed to the WordPress format.

I was going to go into a discussion of the relative benefits of dynamic vs. static publishing, and what a wonderful plugin WP Super Cache is, but this post has run on way too long, so that will have to wait for another day. Until then, here’s an interesting discussion on the subject.

Popularity: 49% [?]

Ch-Ch-Ch-Changes!

Obviously something has happened to TBOTCOTW. I’ve finally switched from MovableType to WordPress. I had a lot of time invested in MovableType, but an upgrade to MT4.1 made most of that moot… many of my hacks didn’t work anymore because none of the more arcane plugins (simple comments, regex, getXML, etc.) were ever updated to work with MT4.

So I realized that the golden days for MovableType were over. There were just too many internal changes from version 2.5 to 3.0, and then again from 3.4 to 4.0, for plugin developers to keep up. Even some of the most dedicated, like Arvind Satyanarayan, had given up on immensely popular plugins like MT BlogRoll. In the comments he got request after request for a new version, and he promised it in a week or two a couple of times, but it’s never happened.

This isn’t Arvind’s fault, of course. He’s a busy young man who just started college. This also isn’t really the fault of MovableType’s developers. The upgrades they did that made plugins break were probably necessary, and I think their vision was (unavoidably) a bit blinkered because they’re developers, not plugin writers (much less plugin users). So they have different priorities than me (and other end-users like me who like to make everything work just so).

WordPress, on the other hand, is purely open source, and always has been. So there seems to be a lot more of the community’s requirements taken into account in new versions. Plus the plugin community feels like MovableType’s did three or four years ago… it’s vibrant and alive, with new plugins released daily and old plugins updated frequently.

The migration was not especially difficult, but I did have to follow these directions to make MT print the EntryIDs in the export file, and to make WP read and use them when importing. This was only because I still get hits with the old entryid format of /archives/001178.html and I have a redirection scheme that sends those hits to the correct entry (basically an extra archive template that’s just a redirect header and a series of archive mappings to each old format). That redirection scheme was very difficult to come up with in MT, but there were a couple of plugins (Advanced Permalinks and Redirection) that made it very, very easy in WP. WP also, out of the box, automatically converts from the underscore format of MT to dashes, which is nice, since I just learned that dashes are preferred by search engines.

Since the upgrade I’ve noticed several things are better. WordPress is noticeably faster than MovableType since it does everything dynamically rather than publishing static html files (it’s even faster than an MT installation with every template set to dynamic publishing). And, like I said before, the plugin selection is pretty incredible. There are several plugins that just do stats reports on visitors, pageviews, and the like. Plus the akismet plugin (which did have a MT version) is native to WP, and it works very well at stopping comment spam. And WP has several features built-in that need plugins or new templates in MT, like a comments feed per post and a blogroll management system.

All in all, I’m extremely happy with WordPress, and not just because I like having new toys to play with.

Popularity: 4% [?]

Server upgrades

I’m working on upgrading my web server to Fedora Core 5 and MovableType 3.31. The first step was to upgrade my mail/DNS server to FC5 and then move all the web stuff to it, both to cut down on downtime and to prove that I could keep both servers ready to run all services at all times in case I have a catastrophic failure on either.

That step is complete, you’re now seeing TBOTCOTW running on MT 3.31 and FC5 on the backup server; that’s why it might seem a tad slow (especially commenting), my mail server is quite a bit older than the primary web server. Other than that the switch should have been pretty much seamless.

If you’re seeing any issues, please let me know.

Popularity: 3% [?]

I’m back

Well, I’m not actually back yet, we don’t fly back to Denver until tomorrow. But I am back from the beach, that barren wasteland of Internet connectivity, so I’ve turned on unauthenticated commenting and trackback publishing.

In other news, the commercial talk at AdActors.com is heating up. Since I’ve been gone three new users registered and two (count ‘em, two!) posts requesting info have been submitted. So if you happen to know the name of the guy David Spade calls “Chubbs” in the Capital One commercials, or that of the girl who speaks fluent Italian in a Secret deodorant ad, please click through and post the answer.

Update: Find out who Chubbs is here, and who the Secret girl is here.

Popularity: 4% [?]

Behind the scenes

Lots of stuff going on at TBOTCOTW, but you probably didn’t notice. I upgraded to Movable Type 3.2, which isn’t a whole lot different than the nightly build I was running previously. Then I set up some alternate skins. If you’re running Firefox (or any Mozilla browser, I think), you can go to View -> Page Style and pick a new one. If you’re running IE or Safari you’re out of luck for now. I’ll set up something in the sidebar to change the skin for those browsers eventually, once I figure out how to make it look nice.

Then I changed my blogroll to MT-Blogroll, which is a neat plugin. But I’m having trouble making its “Recently Updated” feature work. It requires that you dynamically publish your blogroll, but the tags don’t seem to work with dynamic publishing. Someone else in the forum is having the same problem, so hopefully that gets fixed soon. It also doesn’t support click counting without some serious hacking, so I might just delete it and go back to my old blogroll. Update awareness would be really cool, though.

Anyway, lots of technical stuff (and life stuff) going on, so I haven’t had time to update. Hopefully I’ll get a few posts in before Thursday, when I go back to Raleigh for my tenth high school reunion. Sigh, I’m getting old.

Popularity: 3% [?]

New TBOTCOTW server

Zomby complained that my blog was a little slow ealier this week. He was right, commenting was taking up to seventy seconds from pushing the post button to getting the refreshed page. Even dynamic publishing (which I thought would make things very quick) only cut off a few seconds.

So I decided to see if I could get something cheap that would be a big improvement. And what do you know, MicroCenter had an AMD Sempron (a processor I’d never heard of) for $250, with a 150 dollar rebate if you used their credit card. Another 80 bucks to add a half-gig of RAM and I was in business.

Now comment times are down to 15 seconds (and they’re usually much faster than that) and hopefully Andy won’t feel the need to ping me three times anymore because the first two time out.

Alternate post: 100 bucks for a computer that’s at least 100 times more powerful than the one my dad paid 4500 dollars for in 1983? What a great fucking country.

Popularity: 2% [?]

New MT-Notifier coming soon

So I complained a while back that I missed my blog’s “notify me of new comments” feature after upgrading to MT3.2. Well, Chad Everett is working on a new version of his great plugin. MT-Notifier 3.0 will be MT3.2 compatible and will probably be released for a wide audience before the final release of MT3.2. I’m testing it out the beta release here, so please check the “notify me” box if you leave a comment so it has something to do.

It’s got some neat new features. First, it doesn’t require hacking any of the standard Movable Type files like it used to, so it should get along with MT-Blackist and any other plugins you have installed, and it won’t break when you upgrade your MT installation. And it now features notification confirmation, so by default if you sign up you’ll get an email with a confirm link and you won’t get any actual notifications until you click it. If it wasn’t you that plugged your email in then you’ll just get the one email, delete it, and go on about your merry way. Also, it helps to make sure that only real live addresses are in my database.

I had to delete all my old notifications a couple weeks ago because the database was loaded with nonsense addresses and also a few real addresses from people that complained to my SMTP provider that I was spamming them. Between the bounce messages and the threats to have my service cut it just wasn’t worth the trouble. Now I’ll never have that problem again, every comment notification will go to a real person who wants to see it.

Popularity: 2% [?]

Google AdSense ads: Now on TBOTCOTW

Don’t bother refreshing if you don’t see them, they aren’t there… unless you got here via Google. Or, more accurately, unless you got here via Google, Yahoo, or a couple other search engines. Brad Choate gave me the idea, although at this point he’s gone and changed his blog to show ads to every visitor. I might do the same in the future.

What I was actually looking for on Brad’s site was how he prints the ad after the first post on every page, but not after every post. I still haven’t figured that out, so for now I’ve got a banner at the very top of the page and a button in the sidebar (If you want to see what the ads looks like search for “matt moore” in google and hit the “I’m Feeling Lucky” button). Instead I found his brilliant idea to show Google ads only to Google visitors so I don’t penalize my regular readers by trying to make a buck. He used mt-refsearch to display the ads, but that seemed like overkill to me (and that plugin probably isn’t compatible with dynamic pages, anyway). So I wrote a little bit of PHP to do the same thing on a smaller scale.

<?php
$referer = $_SERVER['HTTP_REFERER'];
if ( ereg ( "google.com", $referer ) || ereg ( "altavista.com", $referer )
 || ereg ( "lycos.com", $referer ) || ereg ( "yahoo.com", $referer ) ) {
echo <<<END
<script type="text/javascript"><!--
google_ad_client = "pub-###";
google_ad_width = 125;
google_ad_height = 125;
google_ad_format = "125x125_as";
google_ad_type = "text";
google_ad_channel ="";
google_color_border = "A3B8CC";
google_color_bg = "DAE0E6";
google_color_link = "36419D";
google_color_url = "36419D";
google_color_text = "000333";
//--></script>
<script type="text/javascript"
  src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
END;
}
?>

Of course, fill in your own AdSense code between the END statements. Wherever I stick this script the ad is shown only if the user was referred here by a handful of search engines. Pretty neat, and so far I’ve made 68 cents. Only $99.32 until they cut me a check!

Popularity: 2% [?]

Welcome to Movable Type 3.2b-20050809

Sigh.

Something in my installation of 3.2b3 broke SpamLookup. It would claim, in the log, that it had moderated a comment when it actually just let it through. I tried uninstalling all other plugins, reinstalling SpamLookup, opened a ticket with Brad Choate (who wrote SpamLookup), sent an email to Jay Allen (who wrote MT-Blacklist), and I was just about to reinstall Movable Type entirely when I looked at the Movable Type Beta Blog and saw that they’d released a nightly build for bux fixes. Not only that, it now comes with a new nightly build of SpamLookup designed to be compatible with 3.2. I guess I wasn’t the only one having trouble…

Now everything seems to work great again, except SpamLookup lost the ability to scan old comments and I can’t seem to find where it logs now. That’s what happens when you run beta software (especially nightly builds). Neither is a big deal as long as it functions correctly from now on.

Update: 3.2b-20050809-2. I’m such a beta whore.

Popularity: 2% [?]