From 75c2640ce5d0ff8581fcd5cf5c5dd73f25fd151d Mon Sep 17 00:00:00 2001 From: Jeremy Kersten Date: Thu, 24 Sep 2020 15:13:59 +0000 Subject: [PATCH] [FIX] website: server_page match trailing slash MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit After this commit, if an url with trailing slash is not found we fallback to the url without the slash with a redirect to respect seo. With this change we have the same behavior that controllers. We continue to support trailing slash if page explicitely created with / via backend e.g. and for retrocompatibility. task-2346185 closes odoo/odoo#58603 X-original-commit: 3d65424708d1623654756d58d78cec5f8d71276f Signed-off-by: Jérémy Kersten (jke) --- addons/website/models/ir_http.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/addons/website/models/ir_http.py b/addons/website/models/ir_http.py index ebda40a665a..cd06de4b75a 100644 --- a/addons/website/models/ir_http.py +++ b/addons/website/models/ir_http.py @@ -250,6 +250,10 @@ class Http(models.AbstractModel): # specific page first page = request.env['website.page'].sudo().search(published_domain, order='website_id asc', limit=1) + # redirect withtout trailing / + if not page and req_page.endswith("/"): # / handled by controller + return request.redirect(req_page[:-1]) + if page: # prefetch all menus (it will prefetch website.page too) request.website.menu_id