以下の様なディレクトリがあったとする。 A. htdocs/sslon/ B. htdocs/ssloff/ Aのディレクトリ内は必ずhttp://から始まるURLに、 Bのディレクトリ内は必ずhttps://から始まるURLにしてみるテスト。 htdocsに.htaccessを作成 SSLを有効にするために以下を記述 RewriteEngine On RewriteCond %{HTTPS} off RewriteCond %{REQUEST_URI} ^/sslon/.*$ RewriteRule /.*$ https://%{HTTP_HOST}%{REQUEST_URI} [R,L] これで、/sslon内のコンテンツは必ずsslが有効になり、https://になる。 簡単に説明すると、 まず1行目でRewriteを有効にするため、RewriteEngineに対して引数にOnを与え
![mod_rewriteでディレクトリ別にSSLのON/OFFを切り替える](https://cdn-ak-scissors.b.st-hatena.com/image/square/1cfbec8f224250fbf2ec31d5587739a7a0fd0f93/height=288;version=1;width=512/https%3A%2F%2Fblogger.googleusercontent.com%2Fimg%2Fb%2FR29vZ2xl%2FAVvXsEjHQ6Jmi4XIVgZ7KQiSoEEQxxnC_Hfo7VhBBK9p1dIVUYhWg09UCtwCA56VZ18nSEwhb2yT4RWx146oVhZGd5rucawHeQuBErCKvcH4SA_oyBH843RRUxf6k9oeCzDcgFPSdyPnzOlcCQw%2Fw1200-h630-p-k-no-nu%2Fmod_rewrite_logo.gif)