umbraco / Umbraco-CMS

Umbraco is a free and open source .NET content management system helping you deliver delightful digital experiences.
https://umbraco.com
MIT License
4.37k stars 2.64k forks source link

Make route/URL matching more strict (trailing slash, casing, domains) #12510

Open ronaldbarendse opened 2 years ago

ronaldbarendse commented 2 years ago

Which exact Umbraco version are you using? For example: 9.0.1 - don't just write v9

9.5.0

Bug summary

Currently, content is routed/rendered on more than just the URLs that are visible in the back-office. This means every site will have duplicate content issues, which should really be avoided (e.g. we all want the correct URL indexed and shown in search results).

Specifics

No response

Steps to reproduce

On a clean Umbraco install using the Starter Kit, the contact page is available on the following URL:

Contact URL

But also on the following URLs:


Next, add an extra language (e.g. Dutch) and configure the following domains on the Home page (below Culture and Hostnames):

Culture and Hostnames on Home

This shows the following URLs (including an identical/duplicate absolute URL, as the current base URL is https://localhost:44377/, but that's a different issue):

Contact URLs when using domains

Besides the URLs without a trailing slash or different casing, the contact page is still available on /contact/, which uses the default language. You can check this by rendering the current language in the master template using e.g. <html lang="@Model.GetCultureFromDomains()"> and change the default language to Dutch.

Expected result / actual result

Route matching should be more strict by ensuring:

Either the strict matching should be explicitly enabled to keep backwards compatibility and/or you should be able to configure whether you want to render the content (existing behavior), return a 404 or redirect to the actual/canonical URL.

Returning 404s for URLs without trailing slashes or a different casing would make most sense. For missing domains, it would be best to redirect to the correct/canonical URL instead, preferably based on the users preferred languages (from the Accept-Language browser header) and fallback to the default language configured in Umbraco. This would mean that:

Zeegaan commented 1 year ago

I can reproduce this and agree, putting this up for grabs for now 👍 Worth noting that this would be massively breaking, and thus would need to be for V13 (or later)