お役立ち記事・ブログ
ZendframeworkとEC-CUBEを組み合わせて開発しているときに、.htaccessで一部ディレクトリだけSSL対応させる設定の書き方に2時間ほどハマったので、備忘録としてメモ。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
DirectorySlash On RewriteEngine on RewriteBase / RewriteRule ^(.*)index\.(htm|html)$ $1 [R=301,L] #Rewrite for non-SSL Page RewriteCond %{SERVER_PORT} ^443$ RewriteCond %{REQUEST_URI} !^/(inquiry|mypage|cart|entry|shopping)/.*$ RewriteCond %{REQUEST_URI} !index_zend\.php RewriteCond %{REQUEST_URI} !^.*\.(gif|jpg|jpeg|png|swf|css|js)$ [NC] RewriteRule ^(.*)$ http://%{HTTP_HOST}/$1 [QSA,R,L] #Rewrite for SSL Page RewriteCond %{SERVER_PORT} !^443$ RewriteCond %{REQUEST_URI} ^/(inquiry|mypage|cart|entry|shopping)/.*$ RewriteRule ^(.*)$ https://%{HTTP_HOST}/$1 [QSA,R,L] RewriteRule ^$|^(category|shop|item|inquiry|admin)/.*$ index_zend.php |
上記の設定ですと、inquiry、mypage、cart、entry、shoppingのディレクトリにhttpでアクセスされたときにはhttp→https転送がかかり、それ以外のディレクトリにhttpsでアクセスされたときにはhttps→http転送がかかります。
また、category、shop、item、inquiryディレクトリはEC-CUBEではなくZendframeworkのコントローラーが動きます。
ホームページ・ポータルサイト制作、起業支援に関することはお気軽にご相談・お問い合わせください
TEL:050-3152-1848
電話受付時間:平日9:30~18:30
メールでのお問い合わせは24時間受付OK!(無料)
メール受付はコチラ