I'm using Laravel 5.4 and have a question.
Is it possible to generate an https URL of the specific URL? I have a URL, e.g: login, and want to open it in https, not HTTP.
how can I force Laravel to open url('login')
in https mode?
Asked
Active
Viewed 437 times
0

Meysam Mahmoudi
- 38
- 7
-
Serving the page over `http` vs `https` is configured by your server, not by Laravel. – Tim Lewis Nov 28 '19 at 18:52
-
@TimLewis I've configured both http and https. I don't want to redirect http to https at all I just want to redirect some http url to https. – Meysam Mahmoudi Nov 28 '19 at 18:59
-
1The answer below suggests there a way, and I can't say I know enough about server administration for this, but it seems weird to me to have some routes use `http` but others use `https`. I would think that if you have `https`, everything should use it. See if that works for you though. – Tim Lewis Nov 28 '19 at 19:04
-
@TimLewis actually my default URL uses Http and I only want some specific URL use https. btw thank you and the below answer helped me – Meysam Mahmoudi Nov 28 '19 at 21:07
-
Interesting setup; definitely isn't something I've seen before, but glad you got it working. Cheers! – Tim Lewis Nov 28 '19 at 21:08
2 Answers
2
There is helper function secure_url()
. The secure_url
function generates a fully qualified HTTPS URL to the given path for e.g
$url = secure_url('user/profile');

Aksen P
- 4,564
- 3
- 14
- 27

Ashutosh Kamble
- 193
- 5
1
If you want only some links in https, you can try this (force a group of routes to https):
Route::group(['scheme' => 'https'], function () {
// Route::get(...)->name(...);
});
Similar to this question: How to force Laravel Project to use HTTPS for all routes?

William Prigol Lopes
- 1,803
- 14
- 31