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

plazari96's avatar

Too many redirect when active SSL

Hello Guys,

I'm trying to use Laravel LetsEncrypt (Beta), but when I activate the SSL and refresh the page I have an error ERR_TOO_MANY_REDIRECTS.

Somebody knows and know how to solve?

Thanks!

0 likes
18 replies
bashy's avatar
  • Does Nginx see it as a HTTPS connection?
  • Have you got the sites setup correctly with no duplicate or misconfigured server_names?
  • Do you have any redirects for www/non-www?
1 like
plazari96's avatar

@bashy I set up my server using Forge... I checked the third option about redirects and without https works fine but when I active https have erros!

bashy's avatar

View the vhost config for your site. I can't really say what the issue is without knowing more. You need to do more debugging.

shez1983's avatar

maybe you need to change your base_URL in the .env? does it have http:// by any chance?

also I would go to any URL and for the corresponding method do a dd("dd"); to see if the error is with nginx or actual laravel? (previously I have gotten same too many redirects and it has always been an error with something in my laravel rather than nginx/apache)

jekinney's avatar

Try adding in app/providers/AppServiceProvider in the boot method

If(env(' APP_ENV') !== 'local') { $url->forceSchema('https'); }

This will set all Laravel routes to https including CSS, js and images links.

1 like
bashy's avatar

@jekinney Laravel is pretty much fully protocol oblivious? Which ever one you use HTTP/HTTPS, it will serve files related to the current protocol.

jekinney's avatar

@bashy

Nope. Three weeks ago I deployed a site that was 100% https and though it work, the console had errors that the files (CSS etc) where not https. Took me a few hours researching and googling. The code above fixed the errors and a few redirect issues. Now every call internally is using https, but on homestead http.

jekinney's avatar

By default it http unless you use explicit routes or secure_asset helper.

bashy's avatar

@jekinney Very strange, never had that issue. I've always referenced them with asset(), elixir() etc. It should use the current protocol for those. Which did you use? All the code I've checked for the functions to reference assets/files uses the current protocol.

jekinney's avatar

@bashy

Same as you. Like I said it works and css is correct but in the console I get warning using https and trying to serve http.

shiroamada's avatar

If you deploy in Laravel Forge, there is no need to add Middleware or set in AppServiceProvider boot() for the\URL::forceScheme('https');

If you add it, you put yourselves in too many redirect issue.

Taylor basically already done all the redirect in Nginx Configuration

sheerazabbas's avatar

@alev If some one not able to found Cloudflare -> 'Crypto' tab Just check SSL/TLS -> Overview from left menu and change SSL/TLS encryption mode to Full or Full (strict)

3 likes

Please or to participate in this conversation.