I am finalizing my Laravel 5 project and after purchasing my SSL certificate, I now need to force the route redirection to HTTPS. Is it possible for me to handle this in the app itself instead of the
.htaccess since I have a few domains pointing here:
If you are coming from Laravel 5.7+ then try the following:
- To redirect a request depending the environment you can use App::environment() === ‘production’. For the previous version it was
env('APP_ENV') === 'production'.
\URL::forceScheme('https');actually does not redirect. All it does is to build links with
https://once the website is rendered.