codezero-be / laravel-localized-routes

⭐️ A convenient way to set up and use localized routes in a Laravel app.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

When route has final slash, it will redirect to public/

m-valvano-zakeke opened this issue · comments

Hi!

When I try to redirect to a localized route with the Route::localizedUrl method, if the URL has a final slash it will redirect to the same URL, but with the public/ prefix.

For example, Route::localizedUrl("products") will redirect to "it/products" but Route::localizedUrl("products/") will redirect to "public/it/products".

I have the last version of the package.

Any idea?

Thanks!
Mauro

Hello,

That is rather weird.
But the localizedUrl method was intended for the current URL and accepts a locale instead of a slug.
You probably want this:

// Get specific locales...
// This is most useful if you want to generate a URL to switch language.
$url = route('about', [], true, 'en'); // /en/about
$url = route('about', [], true, 'nl'); // /nl/about

I will see what is going on with that public prefix though...