在 htaccess 中强制使用非 SSL 只能部分起作用
Forcing non-SSL in htaccess only partly works
我已经在我的 htaccess 文件中尝试过此操作,以强制用户通过 SSL 访问我的页面以重定向到非 SSL 版本:
RewriteEngine On
RewriteCond %{HTTPS} on
RewriteRule ^ http://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
这在用户访问 www.mydomain.com 的 SSL 版本而不是 mydomain.com[=23 的 SSL 版本时有效=].
我认为这部分是由于我在我的网络托管服务提供商控制面板上激活了将用户从 mydomain.com 转发到 www.mydomain.com。
有谁知道如何让两者都起作用?
How would the htaccess file look if I want to implement both? That is, forwarding non-www to www, as well as the SSL version of both non-www and www to non-SSL www?
RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule ^ http://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
RewriteCond %{HTTPS} on
RewriteRule ^ http://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
我已经在我的 htaccess 文件中尝试过此操作,以强制用户通过 SSL 访问我的页面以重定向到非 SSL 版本:
RewriteEngine On
RewriteCond %{HTTPS} on
RewriteRule ^ http://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
这在用户访问 www.mydomain.com 的 SSL 版本而不是 mydomain.com[=23 的 SSL 版本时有效=].
我认为这部分是由于我在我的网络托管服务提供商控制面板上激活了将用户从 mydomain.com 转发到 www.mydomain.com。
有谁知道如何让两者都起作用?
How would the htaccess file look if I want to implement both? That is, forwarding non-www to www, as well as the SSL version of both non-www and www to non-SSL www?
RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule ^ http://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
RewriteCond %{HTTPS} on
RewriteRule ^ http://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]