htaccessで特定のディレクトリにSSL通信をする
Apache2.4で.htaccessで特定のディレクトリにSSL通信をします。
ここではadminとcontactディレクトリのみSSLに設定して、
その他のディレクトリはhttp通信とします。
本当は全ページSSL化したほうがセキュリティ的にいいですが、
クライアントの要望により一部だけSSL化したいときに使います。
Rewrite をhtaccessに記述する
adminとcontactディレクトリのみhttps化します。
RewriteEngine on RewriteCond %{REQUEST_URI} /admin/ RewriteCond %{REQUEST_URI} /contact/ RewriteCond %{HTTPS} off RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [R,L] RewriteCond %{REQUEST_URI} !/admin/ RewriteCond %{REQUEST_URI} !/contact/ RewriteCond %{HTTPS} on RewriteRule ^(.*)$ http://%{HTTP_HOST}%{REQUEST_URI} [R,L]
ありがとうございます。おかげさまでうまくいきました。