∅ the empty set

Use Apache's mod_rewrite for beautiful MovableType URLs

MovableType Publising Plateform

If you are an URL fetishist like me, you certainly have been bugged by the fact that MovableType's installation URL kicks in when you need to use MovableType's search function.

Eventhough MovableType can host multiple weblogs each with their own domain natively, it requires a unique URL to its installation directory and the full path to its static directory. These parameters can't be customised on a weblog basis, and prevail for all weblogs driven by the same installation.

If you maintain multiple weblogs, needless to say that it's overkill in terms of support and maintenance to sport one MovableType installation per weblog. So what is the answer if you don't want the install URL to kick in when you run searches in your personalised weblog?

A symbolic link and an Apache's mod_rewrite rule will sort you out.

This weblog makes use of what follows. Although it doesn't offer a search function, it does have a tags page, with all tags being hyperlinked to related posts. This feature typically uses MovableType's search engine.

Moreover and just to complicate things, I use a generic third level domain that points to my MovableType installation: mt.cybmed.com. This brings up the login screen and all subsequent URLs for editing, posting or rebuilding use this domain. It's the domain used in the MovableType setup file (mt-config.cgi), and the search function uses it too.

First, symlink MovableType's installation directory to the weblog's cgi-bin directory. This way, all MovableType's URLs use my domain (davidroessli.com/cgi-bin). Unfortunately, this bans one from using system template elements such as <MTCGIPath> as its uses the configuration parameters. Use <MTCGIRelativeURL> instead, and check the default templates as most of them use <MTCGIPath>.

$ ln -s mt.cybmed.com/cgi-bin davidroessli.com/cgi-bin

Now everything behaves just like if MovableType was installed under davidroessli.com. But the URLs still suck. I can live with ugly admin URLs, but I despise ugly public URLs. So this is what I did:

  1. Rewrite your search URLs in your templates to get rid of the default ones;
  2. Rewrite your new search URLs with mod_rewrite to call the appropriate one.

My tags page uses the following template:

<div id="cloud">
        <a href="<$MTBlogURL$>tag/<$MTTagName$>" 
            title="This tag has been used <$MTTagCount$> time(s).
            Click to search for related posts."><$MTTagName$></a>

This above syntax can be used in your individual archive template in just the same way.

Add a line to your .htaccess file to catch the /tag/tag_name that looks like:

RewriteRule ^tag/(.*)$ /cgi-bin/mt-search.cgi?tag=$1&blog_id=nn&IncludeBlogs=nn

Where nn is the unique identifier of your weblog (check the URL after you've logged in to MovableType and selected your weblog).

Just the same can be done for searching:

RewriteRule ^search/(.*)$ /cgi-bin/mt-search.cgi?q=$1&blog_id=nn&IncludeBlogs=nn

So, with these two simple tips, I have a single MovableType installation to maintain, and all my weblogs use URLs belonging to their own domain that look pretty and are easy to remember.

Use a template to maintain my .htaccess file

Tip: I create a template for my .htaccess file. I find it much easier to use and maintain this way. Just make sure you don't rebuild it each time you rebuild your site. Another ressource to have handy when you're writing RewriteRules is Dave Child's mod_rewrite cheat sheet.

Ø permalink: https://davidroessli.com/logs/2007/04/use_apaches_mod_rewrite_for_be/

Reponses to “Use Apache's mod_rewrite for beautiful MovableType URLs”

#1 by gid

06:12 on 8 June 2007

This is close to what I have been looking for. The problem is that the keywords in your urls are separated by underscores, which almost defeat the purpose of rewriting the urls. I think most people rewrite their urls for search engines and the little extra boost they give.

#2 by Will

05:40 on 18 November 2008

Great tutorial. I've got the same issue, a separate domain for a single MT install driving multiple blogs.

I want to your technique for one of the blogs I've got running, but don't want to break the others.

Say I've got Movable Type installed at:


publishing different blogs to different domains (all on the same server):


If I create a symlink between...

mt.example.com/cgi-bin and domain1.com/cgi-bin

...what happens with the other domains that are referencing mt.example.com/cgi-bin? Will they still work as usual with the ugly urls or will they break?


#3 by David Roessli

08:17 on 19 November 2008

@Will: I believe they should work just fine :)

#4 by Culture Snob

18:21 on 21 January 2009

Thanks for the tutorial. Is there any easy-to-understand tutorial on symlink that might make this a little more accessible to those of us who are petrified of the command line?

I've done clean tag-search URLs through .htaccess before, but with my current installation structure (domain1.com and domain2.com using an MT installation in user.host.com), the old rewrite rules don't seem to work. This looks to be a solution, but I'm not familiar with symlink.

#5 by Culture Snob

18:56 on 21 January 2009

Never mind. I think I figured it out.

Thanks again for the tutorial.

#7 by Enrique

14:26 on 2 February 2009

Thanks for the tutorial David, it helped me a lot.
However, how do you deal with the mt-static folder. Now that it is symlinked in the cgi-bin folder, It seems like I can't point to it from my new domain (I'm using MT's StyleCatcher which creates a @import in my CSS to a style inside mt-static.).

Using your technique, should one have a separate mt-static folder per domain/blog? Or could one simply create a symlink of the mt-static folder somewhere out of the cgi-bin folder? Not sure if I'm very clear...

Thanks again! // e

#8 by David Roessli

16:06 on 2 February 2009

@enrique: thanks!!

You are right to point this out. I left it out of the above tutorial beacuse none of its URLs appear in the address bar.

I believe you could symlink a`mt-static` folder into your blog's folder, and it should work just fine.

The configuration takes relative paths too (you don't have to specify a full URL):

StaticWebPath  /mt-static/

So creating a symlink like,

ln -s /somewhere/on/your/disk/mt-static/ /your/blog/mt-static/

should do the trick.

WRT StyleCatcher, I'm not sure about it's default behaviour. I'll give it a look.

Post a comment

(If you haven't left a comment here before, you may need to be approved by the site owner before your comment will appear. Until then, it won't appear on the entry. Thanks for waiting.)

Previous: Airport Disk hangs logout if not unmounted

Next: Damp and powerless


Hello, my name is David Roessli. I am a freelance web designer and developer based in Geneva, Switzerland.

This weblog is an nth attempt to solve my multiple online personalities and weblog/rss feeds burnout issues. (more)


I have been contemplating the idea of upgrading my desktop Mac since this spring. The latest 27" iMac (Quad-Core) seemed the perfect candidate, but the release of Apple's 27" Monitor last September made me stick with the Mac Pro...


The autopsy of an iconic album cover picked up on Kottke.org. A stacked graph of successive radio signals from pulsar CP 1919, in a 1977 astronomy encyclopedia that originated in a 1970 Ph.D. thesis. Fascinating <3...


Check out my latest Flickr ramblings. Mostly day to day cameraphone pictures stolen here and there.

© 2000-2016 David Roessli | v4.1 | as valid xhtml and css as possible | hosted by pair Networks | RSS feeds.