Configure HTTPS redirection to Heroku Laravel instance

I have a Laravel 5 build running on an apache Heroku instance, and I'm trying to make sure all traffic is converted through https, but I am desperately lost.

My SSL certificate is working successfully. However, with Heroku, you cannot directly edit the .htaccess file on your server. Therefore, their recommendation this page is to configure apache_app.conf and tell Heroku to read it by placing it in the Procfile file:

web: vendor/bin/heroku-php-apache2 -C apache_app.conf public/

However, when I do this, almost any HTTPS rewrite rules that I add causes a redirect loop or application error. Here is my current configuration:

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]
+4
source share
1 answer

.htaccess

HttpsProtocol - HTTPS

0

Source: https://habr.com/ru/post/1598314/


All Articles