强制SSL不能与Joomla或htaccess一起使用

我们在Joomla有多个网站。 以下是详细信息。

  • 托pipe在域mydomain.co.in,sub.mydomain.co.in。
  • Amazon EC2实例,位于负载均衡器之后。
  • 我们为* .mydomain.co.in购买了WildCard SSL证书,并在负载平衡器上对其进行了configuration。

我已经把Joomlaconfiguration的Live Sitevariables设置为https://sub.mydomain.co.in 。 当我浏览网站与https://sub.mydomain.co.in或http://sub.mydomain.com ,它工作正常。 但我想强制所有请求https://。

我试图通过

  • 在Joomlaconfiguration中将强制SSLvariables设置为整个站点。
  • .htaccess中添加以下代码

RewriteEngine On RewriteCond %{HTTPS} off RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

但是,没有任何工作,当我做这两个浏览器中的任一个说这个页面有redirect循环 。 我挖了一点,看是否从其他地方发生redirect。

  • httpd.conf中的虚拟主机configuration
  • 任何Joomlaredirect插件。

但是没有导致redirect循环的代码/插件。

谁能帮忙?

提前致谢。

你正在重写条件中检查错误的variables。

由于您正在使用Amazon Elastic Load Balancer终止您的SSL会话,因此实例中的Apache不知道它们是通过HTTPS进入的,并且未设置HTTPS。

ELB根据请求的接收方式将X-Forwarded-Proto标头设置为httphttps 。 您可以检查此标题,以实现redirect。

 RewriteEngine on RewriteCond %{HTTP:X-Forwarded-Proto} !https RewriteRule .* https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]