我有一个运行在apache Heroku实例上的Laravel 5版本,我正在尝试确保所有流量都通过https转换,但是我绝望地丢失了.
我已成功启动并运行SSL证书.但是使用Heroku,您无法直接在其服务器上编辑.htaccess文件.因此他们在this page上的建议是设置一个apache_app.conf并告诉Heroku通过将它放在Procfile中来读取它:
web: vendor/bin/heroku-PHP-apache2 -C apache_app.conf public/
但是,当我这样做时,我添加的几乎任何类型的HTTPS重写规则都会导致重定向循环或应用程序错误.这是我目前的配置:
RewriteEngine on #Normal way (in case you need to deploy to NON-heroku) RewriteCond %{HTTPS} !=on #Heroku way RewriteCond %{HTTP:X-Forwarded-Proto} !https #If neither above conditions are met,redirect to https RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]