1

我们可以只为主页制作 https 吗?

example.com http://example.com www.example.com http://www.example.com

其余所有页面应以 http 开头。

我试过这样但没有用

RewriteCond %{HTTPS} off
RewriteCond %{REQUEST_URI} "^/$"
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}

RewriteCond %{HTTPS} on
RewriteCond %{REQUEST_URI} ^(.*)$
RewriteRule ^(.*) http://%{HTTP_HOST}%{REQUEST_URI}
4

3 回答 3

0

这是不安全的。阅读OWASP a9并设置HSTS 标志以使您的整个网站仅使用 HTTPS。

HTTP 是一个错误,如果你这样做是为了“性能”,那你就是个傻瓜。HTTPS 非常轻量级。

于 2012-11-07T05:35:01.547 回答
0

您还可以在根级别的 .htaccess 中像这样重定向:

DirectoryIndex index.html
Redirect 301 /index.html https://www.website.com/
于 2012-11-06T14:28:31.943 回答
0

没有经过真正的测试,但应该发挥作用

RewriteEngine On

RewriteCond %{SERVER_PORT} !^443$
RewriteRule ^/?$ https://%{HTTP_HOST}/ [R,L]

RewriteCond %{SERVER_PORT} ^443$
RewriteRule !^/?$ http://%{HTTP_HOST}%{REQUEST_URI} [R,L]
于 2012-11-06T14:13:19.047 回答