Apache2.2,(MOD)SSL和MOD Rewrite通过.htaccess

Apache2.2,(MOD)SSL和MOD Rewrite通过.htaccess,apache,.htaccess,ssl,Apache,.htaccess,Ssl,我想做的是: 1) 防止正常的非安全页面显示为安全页面 2) 防止安全页面显示为正常的非安全页面 3) 按链接指定的方式按原样显示安全页面 还要注意的是,有./contact/subscribe,这是安全的,但不是./contact/welcome。我尝试了在网上找到的一些条件和规则,但我遇到了麻烦——无休止的重定向等等 感谢您对这方面的任何想法,因为我在哪里都找不到:(例如,试试这些 <IfModule mod_rewrite.c> ## redirect anything t

我想做的是:

1) 防止正常的非安全页面显示为安全页面 2) 防止安全页面显示为正常的非安全页面 3) 按链接指定的方式按原样显示安全页面

还要注意的是,有./contact/subscribe,这是安全的,但不是./contact/welcome。我尝试了在网上找到的一些条件和规则,但我遇到了麻烦——无休止的重定向等等


感谢您对这方面的任何想法,因为我在哪里都找不到:(

例如,试试这些

<IfModule mod_rewrite.c>
  ## redirect anything that is not secure and is in folder secure-pages to the secure version
  RewriteCond %{HTTPS} !=on
  RewriteRule ^secure-pages/(.*)$ https://example.com/secure-pages/$1 [R=301,L]

  ## 301 redirect and force contact/subscribe to be secure
  RewriteCond %{HTTPS} !=on
  RewriteRule ^contact/subscribe$ https://example.com/contact/subscribe [R=301,L]

  ## 301 redirect and force contact/subscribe to be NOT secure
  RewriteCond %{HTTPS} =on
  RewriteRule ^contact/welcome$ http://example.com/contact/welcome [R=301,L]

</IfModule>

##将文件夹安全页面中不安全的内容重定向到安全版本
RewriteCond%{HTTPS}!=on
重写规则^secure pages/(.*)$https://example.com/secure-pages/$1[R=301,L]
##301重定向并强制联系/订阅安全
RewriteCond%{HTTPS}!=on
重写规则^contact/subscribe$https://example.com/contact/subscribe [R=301,L]
##301重定向并强制联系人/订阅不安全
RewriteCond%{HTTPS}=on
重写规则^contact/welcome$http://example.com/contact/welcome [R=301,L]