今日のWebアクセシビリティ:Movable Typeで行う404エラー対策
2007年2月25日 04:40
「Not Found」のエラー表示だけですませるのは、もったない
Google等のサーチエンジンや、リンク集をたどった結果、「Not Found.」とか、「404 File Not Found.」とか「Error 404」などのメッセージを見たことはないだろうか?
これは、「リンク先のページがありません」というサーバからのエラーメッセージで、リンクのアドレスが間違っているか、リンク先が公開を停止したり、別のアドレスに引っ越した可能性がある場合に表示される。
さて、本題。Movable Typeはカテゴリーを簡単に編集できるから、サーチエンジンからリンクをたどると、頻繁にこのエラー表示が表示されて泣かされる。
多くはページがなくなったわけではなく、単にURLが変わっただけだから「Not Found.」とか、「ページが見つかりません。」だけでなく、検索機能をつけるなどして、探しにきたページにたどりつくようにしてあげるのといいと思うのだ。
で、カテゴリーを整理したのを機会に、僕のブログでも、エラー表示のテンプレートを修正してみたので参考にしてほしい。MT3.2、MT3.3ならば、やり方は実に簡単だ。
1. ".htacces"の設定
オリジナルの404エラーページは.htaccessに下記内容の記述がないと表示されないが、公開の設定で、ダイナミック・パブリッシングを選んでいる人は、以下の記述の.htaccessが自動的に作られる。
[すべてをスタティックHTMLで出力します](初期仕様)を選んでいる方は下記内容の.htaccessを作りアップロードする必要がある。
## %%%%%%% Movable Type generated this part; don't remove this line! %%%%%%%
# Disable fancy indexes, so mtview.php gets a chance...
Options -Indexes +SymLinksIfOwnerMatch
<IfModule mod_rewrite.c>
# The mod_rewrite solution is the preferred way to invoke
# dynamic pages, because of its flexibility.# Add mtview.php to the list of DirectoryIndex options, listing it last,
# so it is invoked only if the common choices aren't present...
<IfModule mod_dir.c>
DirectoryIndex index.php index.html index.htm default.htm default.html default.asp /mtview.php
</IfModule>RewriteEngine on
# don't serve mtview.php if the request is for a real directory
# (allows the DirectoryIndex lookup to function)
RewriteCond %{REQUEST_FILENAME} !-d# don't serve mtview.php if the request is for a real file
# (allows the actual file to be served)
RewriteCond %{REQUEST_FILENAME} !-f
# anything else is handed to mtview.php for resolution
RewriteRule ^(.*)$ /mtview.php [L,QSA]
</IfModule><IfModule !mod_rewrite.c>
# if mod_rewrite is unavailable, we forward any missing page
# or unresolved directory index requests to mtview
# if mtview.php can resolve the request, it returns a 200
# result code which prevents any 4xx error code from going
# to the server's access logs. However, an error will be
# reported in the error log file. If this is your only choice,
# and you want to suppress these messages, adding a "LogLevel crit"# directive within your VirtualHost or root configuration for
# Apache will turn them off.
ErrorDocument 404 /mtview.php
ErrorDocument 403 /mtview.php
</IfModule>
## ******* Movable Type generated this part; don't remove this line! *******
2. テンプレートの編集
メイン・メニュー > ブログ名 > テンプレート > システムを開き、[ダイナミックページ・エラー]をクリック。
ソースの<boby>~</body>を任意に編集して保存する。このブログでは、断りの他に、検索機能、カテゴリーアーカイブメニュー、月別アーカイブメニュー、タグクラウドをつけた。
3. 404エラーページの確認
確認は簡単、ありもしないURLを入力すればいい。
試しにhttp://www.dakiny.com/seo/をクリックし、確認したら戻ってきてほしい。
電話番号や住所の移転通知サービスみたいなものと思えばわかりやすいと思う。
目的のコンテンツにたどりついた場合と、たどりつけなかった場合の差は決して小さくはない。
Movable Typeでなくても、.htaccessを利用して簡単にできるので、オリジナルの404エラーページを作り、迷える読者に目的コンテンツにたどりつけるようにしてあげるといいと思う。
参考になれば幸い。
投稿者: Dakiny 日時: 2007年2月25日 04:40 |
|
|
| パーマリンク | コメント(0) | トラックバック (0)
トラックバック
このエントリーのトラックバックURL:
http://www.dakiny.com/mtos/mt-tb.cgi/1359
※文章内容と関係のないトラックバックは固くお断り。





