我想做的是下面的,
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>
关于Apache 2.2,(.htaccess 中的 MOD_SSL 和 Mod_rewrite,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1917328/