Skip to content

Route::redirect() does not work #119

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
gerardnll opened this issue Feb 21, 2025 · 1 comment
Open

Route::redirect() does not work #119

gerardnll opened this issue Feb 21, 2025 · 1 comment

Comments

@gerardnll
Copy link

gerardnll commented Feb 21, 2025

Hello, first of all. Thanks for the package!

I'm trying to redirect the home page (/) to another localized section but I'm not having any luck so far.

Route::localized(function () {
    Route::name('front.')
        ->group(function () {
            Route::redirect('/', Lang::uri('events'))->name('home');

            Route::name('events.')->group(function () {
                Route::get(Lang::uri('events'), ListEventsController::class)->name('index');
            });
        });
});

I would like to go from domain.com => domain.com/en/events but I'm not able to get it to work.

Is this supported? Am I not reading the documentation properly?

Thanks a lot.

@gerardnll
Copy link
Author

gerardnll commented Feb 24, 2025

I've noticed that if I turn that Route::redirect to the following, it works.

Route::middleware(SetLocale::class)
    ->get('/', function () {
        return redirect()->route('front.events.index');
    })->name('home');

If I want to redirect the base domain to a route I also have to add another redirect outside the Route::localized() group.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant