平成30/ 2018-10-24 08:58
mod rewrite http https アクセス ssl リダイレクト
Firefox の場合、キャッシュあると、変な動きするので、消してから動作確認すること!!

[L] でNot Foundだが、

[L,R] では、OK!なぜ?

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteCond %{REQUEST_URI} ^/request_.* [OR]
    RewriteCond %{REQUEST_URI} ^/teacher/.*
    RewriteCond %{SERVER_PORT} !^443$
    RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R]

    RewriteCond %{REQUEST_URI} !^/request_.*
    RewriteCond %{REQUEST_URI} !^/teacher/.*
    RewriteCond %{REQUEST_URI} !^/common/.*
    RewriteCond %{REQUEST_URI} !^/images/.*
    RewriteCond %{SERVER_PORT} ^443$
    RewriteRule ^$ http://%{HTTP_HOST}%{REQUEST_URI} [L,R]


    RewriteRule ^pref/([0-9]+)/ /list/?area_id[]=$1 [L]
    RewriteRule ^area/([A-Z]{1}[0-9]{1})/ /list/?area_code=$1 [L]
    RewriteRule ^s_area/([A-Z]{1}[0-9]{1})/ /list/?s_area_code[]=$1 [L]
    RewriteRule ^subject/([0-9]+)/ /list/?subject_id[]=$1 [L]
    RewriteRule ^feature/([0-9]+)/ /list/?feature_id[]=$1 [L]
    RewriteRule ^keyword/([^/]+)/ /list/?keyword=$1 [L]
</IfModule>

//----- wwwなし → wwwありにする
<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteCond %{HTTP_HOST} !^www
    RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
</IfModule>