sites:redirect
文書の過去の版を表示しています。
リダイレクト(.htaccess)
ウェブサイトの移転やページのURL変更時に「.htaccess」にリダイレクト(転送)を記述することで旧サイト(ページ)から新サイト(ページ)に転送します。また検索エンジンの評価も引き継がれます。
よく使う301リダイレクト
ページ単位の転送
「aaa.html」から「bbb.html」へ転送
RewriteEngine on RewriteRule ^aaa.html$ https://www.example.com/bbb.html [L,R=301]
ディレクトリ単位の転送
「/aaa/」から「/bbb/」へ転送
RewriteEngine on RewriteRule ^aaa(.*)$ /bbb$1 [L,R=301]
ドメイン単位の転送
「https://www.aaa.com」から「https://www.bbb.com」へ転送
RewriteEngine on RewriteCond %{HTTP_HOST} ^www.aaa.com RewriteRule ^(.*)https://www.bbb.com/$1 [R=301,L]
URLの正規化
「www.なし」を「www.あり」へ転送
RewriteEngine on RewriteCond %{HTTP_HOST} ^aaa\.com RewriteRule ^(.*)https://www.aaa.com/$1 [L,R=301]
「index.htmlあり」を「index.htmlなし」へ転送
RewriteEngine on RewriteCond %{THE_REQUEST} ^.*/index.html RewriteRule ^(.*)index.html$ https://aaa.com/$1 [L,R=301]
サブドメインからルートドメインへ転送
RewriteEngine on RewriteCond %{HTTP_HOST} ^sub\.aaa\.com$ RewriteRule (.*)https://aaa.com/$1 [R=301,L]
SSL化
「http://www.aaa.com」から「https://www.aaa.com」へ転送
RewriteEngine on RewriteCond %{HTTPS}off RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
エラーページへリダイレクト
エラーページ「error.html」へ転送
ErrorDocument 404 /error.html
sites/redirect.1730965519.txt.gz · 最終更新: 2024/11/07 16:45 by peconet