SSLを設定すると、以下の4種類のアドレスが存在することになる。
- http://ebitainote.com
- http://www.ebitainote.com
- https://ebitainote.com
- https://www.ebitainote.com
これをhttps://ebitainote.comのアドレスひとつに統一する。他の3つをApache(Webサーバー)のmod_rewrite機能を使い転送する。
アドレスを統一させる必要性
手順
1.ファイルの追記
.htaccessファイルの変更
※階層はpublic_html直下
SetEnvIf Request_URI ".*" Ngx_Cache_NoCacheMode=off SetEnvIf Request_URI ".*" Ngx_Cache_StaticMode RewriteEngine on RewriteCond %{HTTP_HOST} ^www\.ebitainote\.com$ RewriteRule ^(.*)$ https://ebitainote.com/$1 [R=301,L] RewriteEngine On RewriteCond %{HTTPS} !on RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L] RewriteEngine On RewriteBase /wp/ RewriteRule ^index\.php$ - [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /wp/index.php [L]
2.ワードプレスの設定
設定 一般
httpからhttpsにリダイレクト