http://www.あああ.com/?post=12345 だった旧URLを、/new.html に転送する方法
URLの末に?を付けて、「名前=値」の形式で表記するのがクエリ文字列(クエリストリング、クエリパラメータ)
旧URLの場合、「post(名前)=12345(値)」が該当
.htaccessで301リダイレクトの設定をする場合、クエリ文字列が入ったURLはRewriteRuleの前にRewriteCondを記述しないといけないらしい。
RewriteEngine on
RewriteCond %{QUERY_STRING} ^post=12345$
RewriteRule ^/?$ /new.html? [R=301,L]
RewriteCond %{QUERY_STRING} ^post=12345$
RewriteRule ^/?$ /new.html? [R=301,L]
{QUERY_STRING}でクエリ文字列を取得
RewriteCondの条件と合致した場合のみ、処理はRewriteRuleに移行し・・・
/new.htmlに301リダイレクトされた!!
参考にしたサイト:
In general, redirecting URLs is a piece of cake with Apache's .htaccess. The only trick is redirecting based on the URL's query-string value. Doing so...