mod_rewrite を使用してサイトの 1 ページを安全に保つ方法

mod_rewrite を使用してサイトの 1 ページを安全に保つ方法

私のウェブサイト上のいくつかのページのみ、URL へのアクセスを http から https にリダイレクトしたいと思います。

Apache 仮想ホストの書き換えを使用してサイト全体に対してこれを行う方法を知っています。

RewriteEngine On
  RewriteCond %{HTTP:X-Forwarded-Proto} !https
  RewriteRule (.*) https://%{SERVER_NAME}%{REQUEST_URI}

しかし、サイトの 1 ページに対してこれを行う方法はありますか? 例: "www.example.com/protected-page"

答え1

これを試して

RewriteRule ^/protected-page/(.*) https://example.com/protected-page/$1 [R,L]

参照 :http://httpd.apache.org/docs/current/rewrite/intro.html

答え2

私は結局違うことをして、すべてを確保しましたしかし保護されている場合は機能しないページ:

  RewriteEngine On
  RewriteCond %{HTTP:X-Forwarded-Proto} !https
  RewriteCond %{REQUEST_URI} !^(.*loadFormImages.*)
  RewriteRule (.*) https://%{SERVER_NAME}%{REQUEST_URI} [L]
  #RewriteLog /opt/tmp/rewrite.log
  #RewriteLogLevel 3

関連情報