What is MTDynamicHandler?

You can engage Amazon Web Services to host an instance of Movable Type 7. The rates are quite decent: it’s free tier eligible! In fact, an AWS instance of MT is what got me back into the Movable Type ecosystem. And it’s lovely to be back.

Six Apart has two versions of Moveable Type available: nginx and Apache. I chose an nginx instance because I live in 2021, and of course I have a poke around. AWS has a stack of unique stuff associated with their MT install to facilitate the spinup of instances and execution of Perl. They also shipped a Perl module MTDynamicHandler.pm which intrigued me.

Part of what prevented me from playing more with Movable Type recently is my use of nginx and its apparent incompatibility with Dynamic Publishing. Despite a stack of research at the time, I couldn’t work out a way to get nginx to ingest .htaccess and rewrite rules to facilitate dynamic rendering. I could not get my own rewrite rules to work right.

AWS / Six Apart worked around this by using a Perl module to integrate with nginx to import .htaccess rules. It utilises ngx_http_perl_module, and is used in a location block in your nginx.conf:

location / {
     ssi on;
     perl MTDynamicHandler::handler;
     root /var/www/spd.ltd;
}

It rewrites a standard Movable Type .htaccess into something that works with nginx:

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)(\?.*)?$ /arme-test/mtview.php$2 [L,QSA]

is ingested and included in your nginx configuration. It supports standard Movable Type dynamic publishing, as well as Dynamic MTML.

I don’t know enough about nginx to get the actual configuration that is spat out, but it works well.

The MTDynamicHandler.pm module that was included in the AWS instance has no changelog, no byline and no licensing. So, it’s available in this gist.