From 785f1b2940e6dd52d97d27fc42e27b52a597dd2b Mon Sep 17 00:00:00 2001 From: Christian Giupponi Date: Tue, 31 Jul 2018 12:33:06 +0200 Subject: [PATCH] This check if the request page match the locale and the slug. If do not match just do a 301 redirect so the user can see the correct page and the correct url, good for seo purpose. --- Modules/Page/Http/Controllers/PublicController.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Modules/Page/Http/Controllers/PublicController.php b/Modules/Page/Http/Controllers/PublicController.php index d7b2cf693..7c23ef337 100644 --- a/Modules/Page/Http/Controllers/PublicController.php +++ b/Modules/Page/Http/Controllers/PublicController.php @@ -38,6 +38,12 @@ public function uri($slug) $this->throw404IfNotFound($page); + $currentTranslatedPage = $page->getTranslation(locale()); + if ($slug !== $currentTranslatedPage->slug) { + + return redirect()->to($currentTranslatedPage->locale . '/' . $currentTranslatedPage->slug, 301); + } + $template = $this->getTemplateForPage($page); return view($template, compact('page'));