我有一些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://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
答案 0 :(得分:0)
RewriteEngine On
# This will enable the Rewrite capabilities
RewriteCond %{HTTPS} !=on
# This checks to make sure the connection is not already HTTPS
RewriteRule ^/?(.*) https://%{SERVER_NAME}/$1 [R,L]
具体目录:
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.