Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

SyedGhazanfar's avatar

I want to change http into https in laravel 5

I want to change http into https in laravel 5. I have changed in .env file and also add this code if(config('app.env') === 'production') { \URL::forceScheme('https'); } into my AppServiceProvider and RouteServiceProvider

but still its not working. anyone help

0 likes
16 replies
Sinnbeck's avatar

Not working? Certificate error? Or you just get http still? What if you manually type https in the browser?

SyedGhazanfar's avatar

@Sinnbeck basically issue is that, I attached ssl with my hosting and it is successfully attached but when I access my website into the browser my website was run but css and js are not load into the browser.

Sinnbeck's avatar

@SyedGhazanfar Maybe your config is cached. Did you run php artisan config:cache after adding the ASSET_URL ?

Sinnbeck's avatar

@SyedGhazanfar On the server, can you try php artisan tinker, and then asset('test.jpg'). That should give you the url with https, if you have set the env correctly on the server.

SyedGhazanfar's avatar
SyedGhazanfar
OP
Best Answer
Level 1

@Sinnbeck basically laravel block proxies and my project is live on aws ec2, I just allow proxy in trustproxy middleware.

mikailfaruqali's avatar

add this to .htaccess file inside public folder

RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

Please or to participate in this conversation.