嘗試下列的示例
<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>