psst.. this blog is on hiatus.

Slick URLs in Movable Type

If you’re a dorkwad like me, you might’ve looked at the jotsheet URLs and seen that there’s no extension there: no .html, no .php, no .shtml. Here, I can prove it: http://underscorebleach.net/content/jotsheet/2003/11/eu_budget

How do I do that? Good question. But first, you ask, why do I do that?

  1. It makes the URLs future-proof: if my server-side approach (currently SSI) changes to PHP, there’s no need to change the file extension on all the files. Also, the same URL can be bookmarked, and you don’t have to mess with redirecting old URLs in a big honkin’ .htaccess (if you’d even bother with that).
  2. Since Google
  3. It looks cool. Nerd power. Uhh yeah

So, since it might be of some use to another small-time nerd out there, I figure I’ll share my approach to extensionless blog entries in Movable Type. It takes a little bit of doing, but by the time you’re done, you’ll be the coolest blogger on the block.

If you’ve reached this page because you’ve searched the Web for how to rip the extensions off your entries, you’ve probably already perused Mark Pilgrim’s approach. I think this is a good start, but I don’t like his use of the Keywords field. In Mark’s approach, you use the Keywords field as a place to store the “URL title,” so that if you fill in the phrase “tom’s test entry” in the Keywords, the permalink becomes something like:
http://www.yourwebsite.com/journal/2004/01/toms_test_entry

This is a good start, but it has two main disadvantages.

  1. You must use the Keywords field to set the entry’s filename, which can be unnecessary if the regular Title field is already short, tidy, and descriptive.
  2. Since you’re always using the Keywords field to generate the filename, it’s not storing actual keywords anymore. It’s lost its purpose.

Dave Dribin improves on Mark’s ideas by using the short_title.pl plugin, which he wrote, allowing one to both use MT’s keywords as intended (for search purposes) and as a place to specify the filename. In fact, most of my approach is based Dave’s excellent primer on Fixing Movable Type’s Permalink URL’s.

Dave and Mark leave the door open as to how to set up archiving, but for me, the decision was simple. Just name the file “index” (sans extension), reaping the same benefits as those detailed above for individual entry permalinks. To do so, stick something like this in your MT’s Weblog Config > Archiving section (this is my configuration for Category archives):

<$MTArchiveCategory dirify="1"$>/index

Also, Dave doesn’t go quite far enough in his otherwise excellent explanation. To rip the extensions off your files, you’ve gotta futz around (definition) with Apache, too. (You are running Apache, not silly IIS, right?) So fire up your favorite text editor (pico, anyone?), and place the following in your text in a .htaccess file in your top-level blog folder:

DirectoryIndex index index.html index.htm index.php
<FilesMatch "^[^.]*$">
SetHandler server-parsed
ForceType text/html
</FilesMatch>

The first line (DirectoryIndex) forces Apache to treat our extensionless “index” file as the default index file for the directory. The next four lines basically tell the server, “If the file doesn’t have an extension, serve it to the browser as an HTML file.” This is done in the HTTP header.

Well, that’s about all I’ve got. If you’re interested in being Internet-cool (and let’s face it, who isn’t?), read Dave’s better-than-mine documentation, and if you’re curious, take a look at Mark’s post for more background.

One Response to “Slick URLs in Movable Type”

  1. 1
    Kim Briggs Says:

    Yes. That’s exactly what I was looking for. HTML … PHP … Java? … ??? It makes a lot of sense for URLs NOT to have file extensions.

    Thanks T-bone.