简体   繁体   English

通过.htaccess的Apache 2.2,(MOD)SSL和Mod重写

[英]Apache 2.2, (MOD) SSL and Mod Rewrite via .htaccess

What i want to do is the following, 我想做的是以下几点,

1) Prevent normal non secure pages being shown as secure 2) Prevent secure pages being shown as normal non secure pages 3) Show secure pages as is, as specified by their links 1)防止将正常的非安全页面显示为安全2)防止将安全页面显示为正常非安全页面3)按其链接指定的原样显示安全页面

Also note there are, ie ./contact/subscribe which is secure but not ./contact/welcome. 还请注意,有../contact/subscribe是安全的,但不是./contact/welcome。 I have tried several conditions and rules found on the web but I hit a wall - endless redirects, etc. 我尝试了在网络上找到的几种条件和规则,但遇到了麻烦-无休止的重定向等。

Appreciate any thoughts on this please as I'm getting no where :( 感谢对此的任何想法,因为我无处可去:(

Try some of these for example 尝试一些例如

<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>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM