0
我在.htaccess文件中使用mod_rewrite尝试,但此代码不起作用,它只是给我的错误“过多的重定向”的Apache服务器 - 如何HTTP重定向到https
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
任何帮助将不胜感激
我在.htaccess文件中使用mod_rewrite尝试,但此代码不起作用,它只是给我的错误“过多的重定向”的Apache服务器 - 如何HTTP重定向到https
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
任何帮助将不胜感激
如果您使用cloudflare或AWS或类似的负载平衡或内部路由请求,您需要检查%{HTTP:X-Forwarded-Proto}
标题,而不是%{HTTPS}
变量。
RewriteEngine On
RewriteCond %{HTTP:X-Forwarded-Proto} !https
RewriteCond %{HTTPS} off
RewriteRule^https://%{HTTP_HOST}%{REQUEST_URI} [L]
尝试此'重写规则^ $ https://www.yourdomain.com/$1 [L,R = 301]'代替'重写规则HTTPS(*)(*)://%{HTTP_HOST }%{REQUEST_URI}' – aqq
即时通讯仍然收到相同的错误 – cmelone
您在.htaccess文件中是否有其他规则? – aqq