ホーム WEBデザイン WordPressで簡単にhttps(SSL)を利用する方法。
早速、独自SSLを導入して、httpをhttpsに自動転送しようと思い、.htaccessのファイルを単純にアップすればいいのだと知ってはおりましたが、せっかくのWordPressなので、FTPソフトを使わずにプラグインとかで簡単に編集できないのかなって思っていたら、簡単にできました。
WordPressのみんな使っているであろうプラグイン「All in One SEO Pack」を使えばFTPソフトを使わずに.htaccessファイルを編集、書き換えできちゃいます!
ちなみにWordPressのインストール直後に.htaccessはありませんが、「All in One SEO Pack」をインストールしてFile EditorをActiveにすると自動生成されます。
スポンサーリンク
とにかくAll in One SEO Packをインストール。
まだインストールしていない方は、プラグインメニューから新規追加で「All in One SEO Pack」をインストールしましょう。
![スクリーンショット 2016-03-07 11.35.50](https://i0.wp.com/bbp.jp/wp-content/uploads/2016/03/4625ef7dbb764bda88e2d79024a53478.png?resize=640%2C539&ssl=1)
Feature ManagerからFile EditorをActiveにする
![スクリーンショット 2016-03-07 11.45.06](https://i0.wp.com/bbp.jp/wp-content/uploads/2016/03/09b087063d3e89614bc0e82f43c1d8ba.png?resize=640%2C539&ssl=1)
左のメニューにFile Editorが出るので、クリックし、
デフォルトがrobot.txtの編集タブですが、.htaccessの編集タブに切替えます。
![スクリーンショット 2016-03-07 11.45.56](https://i0.wp.com/bbp.jp/wp-content/uploads/2016/03/37b46fa57efe504b35ed9d4b166e5f95.png?resize=640%2C539&ssl=1)
XServerで利用時のデフォルトが
suPHP_ConfigPath /home/xxxxxxxx/bbp.jp/xserver_php/ AddHandler fcgid-script .php .phps FCGIWrapper "/home/xxxxxxxx/bbp.jp/xserver_php/php-cgi" .php FCGIWrapper "/home/xxxxxxxx/bbp.jp/xserver_php/php-cgi" .phps # 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
ここに
RewriteEngine On RewriteCond %{HTTPS} off RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [R,L]
を追加します。
具体的には、
suPHP_ConfigPath /home/xxxxxxxx/bbp.jp/xserver_php/ AddHandler fcgid-script .php .phps FCGIWrapper "/home/xxxxxxxx/bbp.jp/xserver_php/php-cgi" .php FCGIWrapper "/home/xxxxxxxx/bbp.jp/xserver_php/php-cgi" .phps <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
のようにします。
![スクリーンショット 2016-03-07 11.50.25](https://i0.wp.com/bbp.jp/wp-content/uploads/2016/03/224b535cb9376db831fea69693732796.png?resize=640%2C539&ssl=1)
たったこれだけですべてのページのhttpでの閲覧はhttpsに切替えられます。
https対応はSEO対策に有利であるようですので、力のあるサイトの立ち上げには今後必須になるでしょう。
スポンサーリンク
Twitter でbbpをフォローしよう!
Follow @https_bbp_jpこんな記事もあります。
コメント
プロフィール
![](https://bbp.jp/wp-content/themes/bbp/img/bbp.jpg)
bbb
はWEBデザインと輸出入の仕事をしてます。趣味程度のブログです。キュレーションへの投稿、ページのいいねとシェアに喜びます。