2017-08-13 62 views
0

我在AWS Elastic Beanstalk上有一个Web应用程序,并且SSL正在运行,但我需要确保所有通信都是HTTPS。我认为与我们现有的规则或负载平衡器存在冲突。以下是我们的.htaccess文件中的规则: RewriteEngine叙述在使用其他mod_rewrite规则将HTTP重定向到AWS Elastic Beanstalk负载均衡器上的HTTPS

RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteCond %{REQUEST_URI} !index 
RewriteCond %{REQUEST_URI} !uploads 
RewriteCond %{REQUEST_URI} !.*\.(css¦js|html|png|xml|mp3|m4a) 
RewriteRule (.*) index.php [L] 

RedirectMatch 301 ^/uploads/users/avatar/$ /images/default-user.jpg 

RewriteCond %{REQUEST_URI} uploads 
RewriteRule ^uploads/(.*)/(.*)/(.*)$ /api/index.php/media/load?fileKey=$3 [QSA,L] 

#force https 
#RewriteCond %{HTTP:X-Forwarded-Proto} =http 
#RewriteRule . https://%{HTTP:Host}%{REQUEST_URI} [L,R=permanent] 

的HTTP部分被注释掉。谁能帮我这个?

回答

-1

尝试以下操作:

RewriteCond %{HTTPS} off 
RewriteRule .* https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301] 
RewriteCond %{HTTP_HOST} !^www\. [NC] 
RewriteRule .* https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301] 
+0

我试了一下。它再次给了我ERR_TOO_MANY_REDIRECTS的事情 – SMayne

+0

您提出的规则是唯一的规则吗? –

+0

是的,但这是一个运行在后端的服务器和AWS负载平衡器。被注释掉的版本是推荐的解决方案。 – SMayne

相关问题