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

vasu_vaadah's avatar

Redirect non-www to www in Laravel Vapor

Any idea how to redirect non-www to www using Laravel vapor?

0 likes
6 replies
Creative2's avatar

@vasu_vaadah in case you were referring to hosting your site at www instead of non-www, I was looking around for that today and found you need to change the redirect option in config/vapor.php

/*
|--------------------------------------------------------------------------
| Redirect "www" To The Root Domain
|--------------------------------------------------------------------------
|
| When this option is enabled, Vapor will redirect requests to the "www"
| subdomain to the application's root domain. When this option is not
| enabled, Vapor redirects your root domain to the "www" subdomain.
|
*/

'redirect_to_root' => false,
2 likes
Jancso's avatar

Is there any update for this? I can't find any solution over the whole internet. Also ther is no config/vapor.php

Thanks

gpalmer711's avatar

@jancso If you want to change the vapor config file and it does not exist at the moment, you can run

php artisan vendor:publish --tag=vapor-config
1 like
mgntrn's avatar

@creative2 thanks! Does anyone know how to set this config value per domain instead of globally?

Please or to participate in this conversation.