[[PageOutline]] = Redirect and Rewrite URL = * http://httpd.apache.org/docs/mod/mod_alias.html#redirect * http://httpd.apache.org/docs/mod/mod_rewrite.html * [http://www.pictnotes.jp/?p=135 Pictnotes » RedirectMatch のリダイレクト先URLで、&(アンパサンド)がある場合] * RedirectMatch のリダイレクト先のURLの中に、&(アンパサンド)がある場合、置換されてしまう。 {{{ RedirectMatch ^/test/? http://www.pictnotes.jp?param1=hoge¶m2=fuga ↓ RedirectMatch ^/test/? http://www.pictnotes.jp?param1=hoge/test RedirectMatch ^(/test/?) http://www.pictnotes.jp?param1=hoge¶m2=fuga ↓ RedirectMatch ^(/test/?) http://www.pictnotes.jp?param1=hogeparam2=fuga (&が消えている状態) }}} * &を使うためには、エスケープしてあげればOK {{{ RedirectMatch ^(/test/?) http://www.pictnotes.jp?param1=hoge\¶m2=fuga & -> \& }}} * [http://ysmt.blog21.fc2.com/blog-entry-216.html Freak: mod_rewriteで動的ページを静的ページっぽいURLにする] * [http://www.multiburst.net/project-multiburst/archives/2007/01/07/1923.php クエリー付のリダイレクトは「mod_rewrite」を使うべし : Project MultiBurst] * 以下のようにクエリーがついたURLを、すべて一つのURLにリダイレクトしようとすると、「Redirect」と「RedirectMatch」では無理なようです。 {{{ Redirect /abc/ /def/index.php RedirectMatch /abc/(.*)$ /def/index.php }}} * そもそも、「mod_alias」がクエリーまで扱っていないそうな。。なので、 {{{ /abc/test.cgi?no=1&id=2 }}} * というリクエストが来ても、 {{{ /def/index.php?no=1&id=2 }}} * という風にリダイレクトされてしまう。ということで、こういう場合は、「mod_rewrite」を使うとよい。 * こんな感じ {{{ RewriteEngine On RewriteRule /abc/(.*)$ /def/index.php [R=301,L] }}} * こうすることにより、クエリーはすべて破棄される。