Sep
20
2008

Nicer Permalinks in MovableType



Comments available as RSS 2.0

I recently switched from WordPress to Movable Type for my software blogs. This site still runs WordPress because there are too many extensions which I need. My software blogs though, were just more or less the same site with different colours and about different products. I only use them for posting new release info and it was too much of an ordeal to update five WordPress blogs everytime an update was released.

One of the more annoying things about Movable type is the URL structure it uses by default. Everything is statically published by default, which works quite well and isn’t a problem in itself, but there’s something about seeing a .html or .php extension which makes a site look amateurish.

There’s an easy way to change Movable Type to use permalinks like http://leghumped.com/post-name instead of http://leghumped.com/2008/09/post-name.html

  1. To disable the extensions and make your permalinks prettier, you’ll need to first edit (or create) a .htaccess file in the root of your web directory and add the following lines:

    DefaultType application/x-httpd-php

    So if your site is leghumped.com, copy and paste those lines into leghumped.com/.htaccess. This causes all files without extensions to be served as PHP.

  2. Login to Movable Type and go to Preferences->Publishing, then remove everything in the File Extension box. This makes MovableType save pages without an extension, so they can be served as PHP by Apache.

  3. Optional: For my purposes, having the date in entry posts isn’t really necessary, so to just use the post name instead go to Manage->Templates->Entry and expand the Template Options section at the bottom. Select Custom from the list and change the mapping to %-f.

  4. This will let you use the filename without the PHP extension to access files, but permalinks generated by Movable Type will still include the PHP extension. To change that, add regex="s/\.php$//" to all links generated by MT. Eg: Instead of <$mt:EntryPermalink$>, use <$mt:EntryPermalink regex="s/\.php$//"$>.

Share and Enjoy:
  • Print
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google Bookmarks
  • Blogplay

Comments

Leave a Comment

Login using OpenID or enter your details below to leave a comment.

OpenID
Anonymous


Comment

Powered by WP Hashcash