URLをhttpからhttpsへのリダイレクトしつつ、wwwのありなしも統一するための.htaccessのサンプルコードです。
動作確認はエックスサーバー。
httpsでwwwなしURLに統一したい場合
RewriteEngine on RewriteCond %{HTTPS} off RewriteRule ^(.*)$ https://exapmle.net/$1 [R=301,L] RewriteEngine on RewriteCond %{HTTP_HOST} ^(www\.exapmle\.net)(:80)? RewriteRule ^(.*) https://exapmle.net/$1 [R=301,L]
httpsでwwwありURLに統一したい場合
RewriteEngine on RewriteCond %{HTTPS} off RewriteRule ^(.*)$ https://www.exapmle.net/$1 [R=301,L] RewriteEngine on RewriteCond %{HTTP_HOST} ^(exapmle\.net)(:80)? RewriteRule ^(.*) https://www.exapmle.net/$1 [R=301,L]
コメント
[…] ・httpからhttpsへのリダイレクトしてwwwありなしを統一する […]
[…] ・httpからhttpsへのリダイレクトしてwwwありなしを統一する […]
[…] […]