0

I'm using Laravel 6.16 for a web-app. I've got a SSL certificate set up for the domain and I now need to force all request to use HTTPS protocol.

The default .htaccess file has the following

<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
    Options -MultiViews -Indexes
</IfModule>

RewriteEngine On

# Handle Authorization Header
RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]

# Redirect Trailing Slashes If Not A Folder...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} (.+)/$
RewriteRule ^ %1 [L,R=301]

# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]

I've tried adding this above the default redirect and replacing the default with:

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

But that causes a redirect loop, I believe the deafult is necessary for larvel to rewrite URL's to "pretty" URLs.

Felix
  • 1
  • 1
  • 1
  • What is the redirect loop exactly? How is SSL being managed? Do you have a SSL cert installed directly on the application server? Or do you have an SSL proxy or something else that handles this? Do you have access to the server config? – MrWhite Mar 20 '20 at 13:23

0 Answers0