Apache 如何在同一站点上为http和https设置.htaccess重写?

Apache 如何在同一站点上为http和https设置.htaccess重写?,apache,.htaccess,Apache,.htaccess,我对htaccess重写有一些问题,我需要将我的站点的不同部分重定向到https而不是http,例如登录和新闻部分。我不知道如何用正确的方式来做这件事 所以现在我有 RewriteRule ^login/?$ index.php?p=login [R,L] 我想将其重定向到https,我尝试了以下方法,但似乎不起作用 RewriteRule ^login/?$ https://%{SERVER_NAME}/index.php?p=login [R,L] 但它似乎不起作用。我错过什么了吗

我对htaccess重写有一些问题,我需要将我的站点的不同部分重定向到https而不是http,例如登录和新闻部分。我不知道如何用正确的方式来做这件事

所以现在我有

RewriteRule   ^login/?$  index.php?p=login [R,L]
我想将其重定向到https,我尝试了以下方法,但似乎不起作用

RewriteRule ^login/?$ https://%{SERVER_NAME}/index.php?p=login [R,L]
但它似乎不起作用。我错过什么了吗?我已经重写和所有其他设置,因为他们的工作。我错过了什么

另外,还有什么方法可以让htaccess使用它未设置的另一组规则

更新:

所以我想做的是重写到,然后再重写到。用户看到了:但它实际上在做

特定目录:

RewriteEngine On
# This will enable the Rewrite capabilities

RewriteCond %{HTTPS} !=on
# This checks to make sure the connection is not already HTTPS

RewriteRule ^/?secure/(.*) https://%{SERVER_NAME}/secure/$1 [R,L]
# This rule will redirect all users who are using any part of /secure/ to the same location but using HTTPS.
# i.e.  http://www.example.com/secure/ to https://www.example.com/secure/
# This means if you dont want to force HTTPS for all directories you can force it for a specific sub-section of the site.

更多信息:

这并不能解决我的问题,我知道如何使用http-to-https技巧,但我知道如何将http://www.site.tld/login/重写为https://www.site.tld/login/code,然后进一步重写为https://www.site.tld/index.php?p=login。因此,用户看到:https://www.site.tld/login/,但实际上它正在执行https://www.site.tld/index.php?p=login
RewriteEngine On
# This will enable the Rewrite capabilities

RewriteCond %{HTTPS} !=on
# This checks to make sure the connection is not already HTTPS

RewriteRule ^/?secure/(.*) https://%{SERVER_NAME}/secure/$1 [R,L]
# This rule will redirect all users who are using any part of /secure/ to the same location but using HTTPS.
# i.e.  http://www.example.com/secure/ to https://www.example.com/secure/
# This means if you dont want to force HTTPS for all directories you can force it for a specific sub-section of the site.