我正在使用.htaccess强制使用以下代码重定向到https://www.domain.com:
RewriteEngine On
RewriteCond %{HTTPS} !off
# First rewrite to HTTPS:
RewriteRule .* https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
# Now, rewrite any request to the wrong domain to use www.
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule .* https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
答案 0 :(得分:1)
CloudFlare不使用443端口,请尝试以下方法:
RewriteCond %{SERVER_PORT} 80
答案 1 :(得分:0)
如果出现5xx错误,则会出现服务器问题。检查您的日志并尝试:
RewriteCond %{HTTPS} !on [OR]
RewriteCond "%{HTTP_HOST}" "!^www\." [NC]
RewriteCond "%{HTTP_HOST}" "!^$"
RewriteRule "^/?(.*)" "https://www.%{HTTP_HOST}/$1" [L,R,NE]