【发布时间】:2014-08-19 18:56:31
【问题描述】:
我正在尝试使用运行表达式引擎的站点的 .htaccess 来强制使用 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>
(我已将它们禁用,因为该网站已上线)
【问题讨论】:
标签: .htaccess ssl https load-balancing expressionengine