I try to make a multilingual site on Laravel 5.3

Route::group( ['prefix' => '{lang?}'], function () { Route::get( '/{post}', 'Front\Post@index' )->name( 'post' ); Route::get( '/', 'Front\HomeController@index' )->name( 'home' ); } ); 

If the link is /ru/some-post , the route works correctly and the Front\Post@index controller is called. But if the link is /some-post then the route considers that some-post is the lang parameter, not the post . The idea is that you want to hide the localization from the url for the default language.

Who can that advise in this occasion?

  • Do not use localization in the URL or do not hide the default. Of course this group is too global, it will block all the routes. Believe me, a "game" with routs will not lead to good. As a result, it is possible to do such a thing, which then it will be unclear where and what for. :) Do not complicate, an ordinary user doesn’t look at the URL at all, he doesn’t care about this ru / en in the address bar, and you can keep the chosen language in session. If localization is needed for contextual advertising, simply add a get parameter handler to the software that will give the desired language. - SlyDeath
  • What about SEO? If my url is the same. only depending on the language - is the prefix? - TDev
  • Therefore, usually, the language is put in a subdomain, it's easier. - SlyDeath

0