Skip to content
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

Method $pages->find() should never redirect #3266

Merged
merged 5 commits into from
Mar 17, 2021
Merged

Conversation

mahagr
Copy link
Member

@mahagr mahagr commented Mar 12, 2021

This is my attempt to fix some redirect issues in $pages->find()` method.

It attempts to keep the old behavior with one exception: dispatch() will attempt to find the regexp routes before redirects, which makes more sense than the old behavior.

I have not changed how the blind redirects work (defined in site.redirects configuration), IMHO they should take the path as it is and route accordingly. If you want to redirect a path to an existing page, it's better to use site.routes instead and force redirect by setting system.pages.redirect_default_route to 301/302 instead.

CC: #3004, #2435

@mahagr mahagr requested a review from rhukster March 12, 2021 09:57
@mahagr
Copy link
Member Author

mahagr commented Mar 12, 2021

This pull request will not fix the language redirects needing the language code, but will only separate the logic between find() and dispatch() methods and make site.routes more usable.

For the language codes, I still think that site.redirects should not be based on routes, but they should blindly match the current URL (including query parameters etc) and do transformation based on that.

However it could be a good idea to be able to pass more information to the redirects, such as '{LANG}?/foo/(\d+)': '{LANG}/bar/$2' which would match all language codes.

The reason why I'd like to do it in that way is that you do not want to restrict redirects to Grav routes as you may have migrated from another CMS.

mahagr added a commit that referenced this pull request Mar 17, 2021
@mahagr mahagr merged commit 73bb1f3 into develop Mar 17, 2021
@mahagr mahagr deleted the bugfix/redirects-2435 branch May 20, 2021 14:03
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

Successfully merging this pull request may close these issues.

1 participant