「wwwなし」「index.htmlなし」「httpsのみ」の場合のリダイレクト
以下のコードを.htaccessに記述する。
「hoge.com」というドメインの部分は実際のドメインと差し替える
# URL書き換え有効化
Options +FollowSymLinks
RewriteEngine on
# wwwなしへリダイレクト
RewriteCond %{HTTP_HOST} ^www\.hoge\.com$
RewriteRule ^(.*)$ https://hoge.com/$1 [R=301,L]
# index.htmlをリダイレクト
RewriteCond %{THE_REQUEST} ^.*/index.html
RewriteRule ^(.*)index.html$ https://hoge.com/$1 [R=301,L]
# SSLへリダイレクト
RewriteCond %{HTTPS} !on
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]「wwwあり」「index.htmlなし」「httpsのみ」の場合のリダイレクト
以下のコードを.htaccessに記述する。
「hoge.com」というドメインの部分は実際のドメインと差し替える
# URL書き換え有効化
Options +FollowSymLinks
RewriteEngine on
# wwwありへリダイレクト
RewriteCond %{HTTP_HOST} ^hoge\.com$
RewriteRule ^(.*)$ https://www.hoge.com/$1 [R=301,L]
# index.htmlをリダイレクト
RewriteCond %{THE_REQUEST} ^.*/index.html
RewriteRule ^(.*)index.html$ https://www.hoge.com/$1 [R=301,L]
# SSLへリダイレクト
RewriteCond %{HTTPS} !on
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]

