HDTuto.com

Laravel - How to generate secure https URL from route?


https is a secure url and we know google give first priority to search that use https. So if you have using http only from scratch and if you install ssl certificate then your website will open with https.

So, As we know, If you open with http url then all the links of page will generate with http from route. But if you want to force generate https link from route then you can do it. you can generate https link from route using URL::forceSchema('https').

We have to just force generate https link using "URL::forceSchema('https')" helper in AppServiceProvider.

app/Providers/AppServiceProvider.php

<?php

namespace App\Providers;

use Illuminate\Support\ServiceProvider;

use URL;

class AppServiceProvider extends ServiceProvider

{

/**

* Bootstrap any application services.

*

* @return void

*/

public function boot()

{

URL::forceSchema('https');

}

/**

* Register any application services.

*

* @return void

*/

public function register()

{

//

}

}

Now you can just check it.

I hope you found your best.....






August 3, 2018 | Category : PHP Laravel Laravel 5 Laravel 5.6
Related Posts