Here’s how it looks in routes/web.php:Route::group(['prefix' => '{locale}'], function() { Route::get('/', function () { return view('welcome'); }); Auth::routes(); Route::get('/home', 'HomeController@index')->name('home'); });All the routes above were pre-generated, we just moved them inside of our Route::group().
We add a regular-expression based rule inside of the group:Route::group([ 'prefix' => '{locale}', 'where' => ['locale' => '[a-zA-Z]{2}'] ], function() { // ...
Automated Redirect of HomepageWe need to add another line to routes/web.php – to redirect the user from non-localed homepage to /en/ homepage.
So we need to add locale to the redirect URL.
In our case, all we need to do is add a locale to the route:public function redirectTo() { return app()->getLocale() .
Newsletter

Get the latest Laravel/PHP jobs, events and curated articles straight to your inbox, once a week

Glimpse streamlines Laravel development by seamlessly deploying GitHub pull requests to preview environments with the help of Laravel Forge. Glimpse streamlines Laravel development by seamlessly deploying GitHub pull requests to preview environments with the help of Laravel Forge.
Fathom Analytics | Fast, simple and privacy-focused website analytics. Fathom Analytics | Fast, simple and privacy-focused website analytics.
Shirts painstakingly handcrafted by under-caffeinated developers. Shirts painstakingly handcrafted by under-caffeinated developers.
Community Partners