Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/apache/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Apache 在AWS Elastic Beanstalk负载平衡器上使用附加的mod_重写规则将HTTP重定向到HTTPS_Apache_.htaccess_Amazon Web Services_Mod Rewrite - Fatal编程技术网

Apache 在AWS Elastic Beanstalk负载平衡器上使用附加的mod_重写规则将HTTP重定向到HTTPS

Apache 在AWS Elastic Beanstalk负载平衡器上使用附加的mod_重写规则将HTTP重定向到HTTPS,apache,.htaccess,amazon-web-services,mod-rewrite,Apache,.htaccess,Amazon Web Services,Mod Rewrite,我在AWS Elastic Beanstalk上有一个web应用程序,SSL正在工作,但我需要确保所有流量都是HTTPS。我认为这与我们现有的规则或负载均衡器存在冲突。以下是.htaccess文件中的规则: 重新启动发动机 RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_URI} !index RewriteCond %{REQUEST_URI} !uplo

我在AWS Elastic Beanstalk上有一个web应用程序,SSL正在工作,但我需要确保所有流量都是HTTPS。我认为这与我们现有的规则或负载均衡器存在冲突。以下是.htaccess文件中的规则: 重新启动发动机

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部分被注释掉了。有人能帮我吗?

试试以下方法:

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]

我试过了。它给了我一个错误,太多重定向的东西。你在问题上的规则是唯一的吗?是的,但这是一个运行在AWS负载均衡器后面的服务器。注释掉的版本是推荐的解决方案。