基本はレンタルサーバーでの記述
.htaccess
<IfModule mod_rewrite.c>
RewriteEngine On
# ここに記述をする
</IfModule>
リダイレクト
.htaccess
# 特定のディレクトリをリダイレクト
# AAA.com/news/ → AAA.com/product/news/
RewriteRule ^news/$ product/news/ [R=301,L]
.htaccess
# 特定のページをリダイレクト
# AAA.com/company/about.html → AAA.com/company/
RewriteRule ^company/about.html$ /company/ [R=301,L]
.htaccess
# パラメーター付きURLをリダイレクト
# AAA.com/news/?item=hoge → AAA.com/news/
RewriteCond %{QUERY_STRING} ^item=hoge$
RewriteRule ^news/$ /news/? [L,R=301]
# パラメーター付きURLをリダイレクト(複数つなげることも可)
# AAA.com/news/?item=hoge → AAA.com/news/
# AAA.com/news/?item=foo → AAA.com/news/
# 複数設定する場合は[OR]を指定
RewriteCond %{QUERY_STRING} ^item=hoge$ [OR]
RewriteCond %{QUERY_STRING} ^item=foo
RewriteRule ^news/$ /news/? [L,R=301]
.htaccess
# パラメーター付きURLをリダイレクト
# AAA.com/news/page/2/?item=hoge → AAA.com/news/
RewriteCond %{QUERY_STRING} ^item=hoge$
RewriteRule ^news/page/([0-9]+)/$ /news/? [L,R=301]
「QUERY_STRING」でクエリーを見にいく。
複数指定も可。