Movable Type のアーカイブファイル名設定変更に関する対応

連休中にふと思い立って、Movable Type を 2.x から 3.2 にとうとうアップグレードし、
その際に、アーカイブ形式を変更した。

  • Individual: NNNNNN.html -> YYYY/MM/DD/foobar/index.php
  • Date-based: YYYY_MM.html -> YYYY/MM/index.php
  • Category: cat_foobar.html -> foobar/index.php

ちなみに、過去に再構築された旧形式の .html ファイルは削除はしていない。

Apache のアクセスログを見ていると、Google などからのお客さん、いずれもまだまだ
旧形式でアクセスがある。当たり前だけど。

でも、旧形式はもはや再構築をかけないので、これはちょっと都合が悪い。

ということで、Apache でリダイレクトを設定した。

        RedirectMatch /blog/archives/([0-9]+)_([0-9]+)\.html http://www.example.net/blog/archives/$1/$2/
        RedirectMatch /blog/archives/cat_([a-zA-Z0-9]+)\.html http://www.example.net/blog/archives/$1/

これで、Date-based archive と Category Archive については救済する。
Individual Archive は、新しい URL が、エントリの Title をもとに決定するため、
規則性がない。ひとつひとつマッピングを作る気力もないためあきらめる。

脱線。

redirect 先は http://www.example.net/blog/archives/$1/ でなく、/blog/archives/$1/ でも動いてしまうみたい。昔(いつ?)はだめだった気がする。

http://www.ietf.org/rfc/rfc2616.txt の 14.30 Location でも


Location = "Location" ":" absoluteURI

とあるし、"Location: /blog/archives/foobar/"
なんていう内容で返してはいけない気がする。

と思ったけど、httpd.conf の中にもリダイレクト先が /manual/$1$2 なんていうのがあった。別にいいのか?

About this Entry

This page contains a single entry by dxy published on 2006年5月 8日 21:49.

Google Calendar の文字化け was the previous entry in this blog.

Movable Type コメントやトラックバックの CGI is the next entry in this blog.

Find recent content on the main index or look in the archives to find all content.

Pages

Powered by Movable Type 5.01