ApacheでSSLの有無によってディレクトリを振り分ける方法
読了まで:約2分
概要: Apache を
こんばんみ!
いつも
さて、
分かりやすく
# 例えばブログエンジンの場合
投稿等のページ => https://{project}.fluxflex.com
公開するページ => http://{project}.fluxflex.com
と
で、mod_rewrite
を
前提と条件
fluxflex.com上のプロジェクト名 => {project}
fluxflex.com上の公開ディレクトリ => public_html/
管理ページ用ファイル一式 => public_html/admin
公開ページ用ファイル一式 => public_html/public
.htaccessの在処 => public_html/.htaccess
と
SSL(https)付きのアクセス => public_html/admin以下を表示
SSL無し(http)のアクセス => public_html/pubic以下を表示
したい
.htaccess
は、
ざっと
RewriteEngine On
RewriteBase /
# stopper
RewriteRule ^admin - [[L]]
RewriteRule ^public - [[L]]
# on https
RewriteCond %{HTTPS} on
RewriteRule ^(.*)$ admin/$1 [[QSA]]
# on http
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ public/$1 [[QSA]]
さらっと開設
まず、RewriteEngine On
でmod_rewrite
を
#stopper
の
ちなみにRewriteRule
は、RewriteRule
んで、%HTTPS
にon
かoff
でRewriteCond
なRewriteCond
でのRewriteCond
直下のRewriteRule
にのみ 有効らしいので、
で、RewriteRule
を
ざっと感想
ちなみに、.htaccess
の.htaccess
の
で、
いやぁアレだよ!mod_rewrite
の
まあ、
あ、
とり
ちゃんちゃん。
#FIXME