LoginSignup
1
0

More than 5 years have passed since last update.

SSL設定リダイレクト方法

Last updated at Posted at 2019-03-28

SSL設定リダイレクト方法

http通信をhttpsにリダイレクトさせる方法の1つ。
(他の方法は。default.confにRewriteを書くなどがある)
.htaccessを対象のアプリケーションのpublic/以下に作成しリダイレクトさせる。

.htaccess
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /

# httpからの通信を、httpsにリダイレクト(www有り無し)
RewriteCond %{HTTPS} off
RewriteRule ^(.*$) https://~~~(ドメイン名)/$1 [R=301,L]

# httpsからの通信でwww有りの場合、www無しにリダイレクト
RewriteCond %{HTTPS} on
RewriteCond %{HTTP_HOST} ^www.~~~(ドメイン名)$
RewriteRule ^(.*)$ https://~~~(ドメイン名)/$1 [R=301,L]
</IfModule>
1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0