Open lukasbestle opened 3 years ago
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.
Not stale
This issue has been automatically marked as stale because it has not had recent activity. This is for us to prioritize issues that are still relevant to our community. It will be closed if no further activity occurs within the next 14 days. If this issue is still relevant to you, please leave a comment.
I am not convinced that this behavior is normal, it is rather very strange. I don't know it from other CMS. On the one hand, it is not good when such "wrong" pages are indexed because on a page marked as English, there should be no German texts, for example. In addition, customers do not understand it when they suddenly land on such a page because they do not understand the error behind it.
Maybe you could make it so that you can turn off the behavior if you don't want it?
@schokomeldra I think there is a misunderstanding. This is not about pages with mixed translation texts or missing translations, but about canonical URLs to translated pages. At the moment, you can reach the exact same translated page via different combinations of nested paths (with the original slug and the translated slug of each level). By redirecting all invalid/inconsistent paths to the canonical path, users will still get to the correct page but with the correct URL.
@schokomeldra I think there is a misunderstanding. This is not about pages with mixed translation texts or missing translations, but about canonical URLs to translated pages. At the moment, you can reach the exact same translated page via different combinations of nested paths (with the original slug and the translated slug of each level). By redirecting all invalid/inconsistent paths to the canonical path, users will still get to the correct page but with the correct URL.
I've just stumbled across the same problem! I agree with you, the behavior should be exactly as you described: A translated page with a translated slug should only be accessible under that slug and the original slugs should redirect to the translation via 301/302.
Same here. As a workaround, I added the following code to my site/controllers/site.php
:
$correctUrl = $page->url();
$requestPath = $kirby->path();
if (
strpos($correctUrl, $requestPath) === false &&
strpos($correctUrl, '/error') === false // don't redirect to /error -> keep wrong uri if not exist
) {
// keep query string if it exists
$query = $_SERVER['QUERY_STRING'] ? "?" . $_SERVER['QUERY_STRING'] : "";
return $kirby
->response()
->redirect($correctUrl . $query);
}
Works for me, but use it with caution - I'm new to Kirby & PHP
Same here. As a workaround, I added the following code to my
site/controllers/site.php
:$correctUrl = $page->url(); $requestPath = $kirby->path(); if ( strpos($correctUrl, $requestPath) === false && strpos($correctUrl, '/error') === false // don't redirect to /error -> keep wrong uri if not exist ) { // keep query string if it exists $query = $_SERVER['QUERY_STRING'] ? "?" . $_SERVER['QUERY_STRING'] : ""; return $kirby ->response() ->redirect($correctUrl . $query); }
Works for me, but use it with caution - I'm new to Kirby & PHP
Thank you @Vincenius. I'll take a look at it und test it!
Basic example
URLs:
Request mapping right now:
Expected behavior:
The last three examples should be
HTTP 302
redirects to the canonical URL/de/seite/unterseite
.Complex example
This works at the moment and there needs to be a unit test to verify that we don't break this behavior.
URLs:
Expected routing:
Background context
See #2257.