
私のウェブサイト上のいくつかのページのみ、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]
答え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