はじめに
WordPressサイトを常時SSL化したのでhttpからhttpsにリダイレクトしてみる
環境
サーバー お名前共用サーバ SD-11プラン
Wordpress version 4.7.7
設定方法
WordPressのpluginを使うことも考えましたが今回は.htaccessファイルで設定する方法です
①.htaccessファイルを開く
(Wordpressインストール時作成したホームフォルダ直下にあります)
②以下の2行を追加する
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [R,L]
実際の.htaccessファイルはこんな感じ
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [R,L]
</IfModule>
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress