htaccess https redirect only on specific Zend Frameworks controller/actions

前端 未结 4 1458
夕颜
夕颜 2021-01-27 05:41

I\'m new to this community, but I\'ve found it really useful time to time.

I\'ve searched for the answer a lot, but I didn\'t find anything like I need. I\'ve tried to s

4条回答
  •  旧时难觅i
    2021-01-27 06:23

    Try these rules instead (replace appropriate lines):

    RewriteCond %{HTTPS} on [NC]
    RewriteCond %{REQUEST_URI} !^/(member|shop)/ [NC]
    RewriteRule ^(.*)$ http://%{HTTP_HOST}/$1 [L,R=301]
    
    RewriteCond %{HTTPS} off [NC]
    RewriteCond %{REQUEST_URI} ^/(member|shop)/ [NC]
    RewriteRule ^(.*)$ https://%{HTTP_HOST}/$1 [L,R=301]
    
    1. These rules a bit simple (HTTPS will be applied to ALL URLs in /member/ and /shop/ controllers (e.g. /member/login, /member/dashboard, /member/orders/15423/invoice etc)
    2. Negate ! should be before ^ in RewriteCond directive -- if you want your own rules then replace RewriteCond $1 ^!((member|shop)/(?!(index|login))(.*)) by RewriteCond $1 !^((member|shop)/(?!(index|login))(.*))

提交回复
热议问题