Warm tip: This article is reproduced from serverfault.com, please click

Laravel generate secure https URL from route

发布于 2014-06-26 09:01:45

Edit

I can't really find a way to generate a secure URL from route name.

To get a full URL, I use

echo route('my_route_name');

But what to do, if I want a URL with https?

Questioner
Mārtiņš Briedis
Viewed
0
Mārtiņš Briedis 2014-09-12 19:15:39

Actually turns out, that laravel doesn't care if url is secure or not, because it generates based on the current url. If you're on https page, route() will return secure url. If on http, then http:// url

The problem was, that Laravel didn't detect that https was enabled, which was due to faulty server configuration.

You can check if Laravel sees the current connection as https by calling Request::isSecure();