我试图强制使用运行表达式引擎的网站的.htaccess进行HTTPS。 截至目前,您可以使用https://访问该网站,但是当我添加这些规则时,它会显示重定向循环。在表达式引擎重定向循环上强制HTTPS
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{SERVER_NAME}%{REQUEST_URI} [R=301,L]
或
RewriteCond %{SERVER_PORT} !^443$
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
或
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://mydomain.com/$1 [R,L]
,也看中了这一个
RewriteCond %{HTTP:X-Forwarded-Proto} !https
RewriteRule !/status https://%{SERVER_NAME}%{REQUEST_URI} [L,R]
,我也试着重新安排所有的规则对他们每个人如此我很确定它有什么关系条件匹配时,他们不应该。
我也看到了有关负载平衡器重定向的事情有些事情从这里专柜的.htaccess : .htaccess redirect loop when trying to add forced HTTPS rule (Amazon Elastic Beanstalk)这里:https://serverfault.com/questions/283525/force-ssl-on-one-page-via-htaccess-without-looping
我觉得我的客户正在使用INMOTION托管,但我用不上到负载均衡器设置,所以我想确保这是问题。
这里是整个htaccess。我删除了一些默认的表达式引擎,但是在我这样做之前它也没有工作。
<IfModule mod_rewrite.c>
# Enable Rewrite Engine
# ------------------------------
RewriteEngine On
RewriteBase/
# RewriteCond %{HTTPS} off
# RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
# RewriteCond %{HTTP:X-Forwarded-Proto} !https
# RewriteRule !/status https://%{SERVER_NAME}%{REQUEST_URI} [L,R]
# Redirect index.php Requests
# ------------------------------
RewriteCond %{THE_REQUEST} ^[^/]*/index\.php [NC]
RewriteCond %{THE_REQUEST} ^GET
RewriteRule ^index\.php(.+) $1 [R=301,L]
# Standard ExpressionEngine Rewrite
# ------------------------------
RewriteCond $1 !\.(css|js|images|gif|jpe?g|png) [NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php/$1 [L]
</IfModule>
(我有他们禁用,因为该网站是活的)