if you are creating this route on https it should return https, and redirecting all http sites to https is basically the work of your web server (nginx/apache)
Jul 24, 2015
5
Level 1
Forcing Lumen to use HTTPS
How can I tell Lumen to make all routes/requests etc via HTTPS?
Say route('page') = /page
It'll generate a link like: http://example.com/page
How can I get it to generate https://example.com/page instead?
Level 1
Level 1
Not intending to bump this old post, but I also have the same issue where on a HTTPS url it's using non https links. Any ideas?
Level 4
I've got the same issue... just as a belated +1 on this :/
Level 1
You can control it with htaccess. Try this, it should work fine
AddDefaultCharset UTF-8
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>
RewriteEngine On
#Redirect to HTTPS
RewriteCond %{HTTP:X-Forwarded-Proto} !https
RewriteRule !/status https://%{SERVER_NAME}%{REQUEST_URI} [L,R]
# Redirect Trailing Slashes If Not A Folder...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/$ /$1 [L,R=301]
# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>
I added this to the default htaccess content
#Redirect to HTTPS
RewriteCond %{HTTP:X-Forwarded-Proto} !https
RewriteRule !/status https://%{SERVER_NAME}%{REQUEST_URI} [L,R]
2 likes
Level 1
Instead with a few modification in above answer as the above answer leads to infinite redirect error
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>
RewriteEngine On
#Redirect to HTTPS
RewriteCond %{HTTPS} !on [OR]
RewriteCond %{HTTP_HOST} ^www\. [NC]
RewriteRule ^ https://api.havemybooks.com%{REQUEST_URI} [L,NE,R=301]
# Redirect Trailing Slashes If Not A Folder...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/$ / [L,R=301]
# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
# Handle Authorization Header
RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
</IfModule>
Please or to participate in this conversation.