[英]htaccess force https and redirect www to non-www, but no other subdomains
[英]htaccess eliminate www then redirect all non subdomains traffic to https
我已经尝试了10种不同的配置,所有这些都在这里找到答案,但最终我得到的只是一个重定向循环。
我的最新尝试如下:
RewriteCond %{HTTP_HOST} ^www.test.com
RewriteRule (.*) http://test.com/$1 [R=301,L]
RewriteCond %{HTTP_HOST} !^(.*?)\.test.com$
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
在前两行中,我消除了www
然后,我正在检查没有子域,如果已经设置了https,那么我正在重定向。
最后,我要检查现有文件等,并通过index.php发送所有流量
RewriteCond %{REQUEST_FILENAME} !-l
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule .* index.php?%{QUERY_STRING} [L]
谁能发现明显的错误?
此规则将忽略用于http->https
重定向的子域:
RewriteCond %{HTTPS} off [OR]
RewriteCond %{HTTP_HOST} ^www\.test\.com$
RewriteRule ^ https://test.com%{REQUEST_URI} [NE,R=301,L]
PS:这也将取代您的第一个www删除规则。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.