0

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?

5
  • Serving the page over http vs https is configured by your server, not by Laravel. Commented Nov 28, 2019 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. Commented Nov 28, 2019 at 18:59
  • 1
    The 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. Commented Nov 28, 2019 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 Commented Nov 28, 2019 at 21:07
  • Interesting setup; definitely isn't something I've seen before, but glad you got it working. Cheers! Commented Nov 28, 2019 at 21:08

2 Answers 2

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'); 
Sign up to request clarification or add additional context in comments.

1 Comment

Thanks, This is what I was looking for.
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?

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.