PiranhaCMS / piranha.core

Piranha CMS is the friendly editor-focused CMS for .NET that can be used both as an integrated CMS or as a headless API.
http://piranhacms.org
MIT License
2.02k stars 561 forks source link

Alias routing case sensitivity #2087

Open Memoryfox opened 3 months ago

Memoryfox commented 3 months ago

Hello,

we have migrated some older ASPX sites to Piranha and have defined a lot of aliases. After a few weeks running we detected many 404 errors, although aliases were defined for the requested URLs. The reason for this is the different case sensitivity of the requested URLs.

With cache turned on, the alias lookup is always case sensitive (direct comparison). Without cache it depends on the database (i. e. collation on SQLServer).

Example: Alias: /public/support.aspx -> /support Request 1: /public/support.aspx -> redirected Request 2: /public/Support.aspx -> 404 Not Found

The different case sensitivity of old URLs is due to historical reasons. It is also possible for users to enter a URL manually in the browser and save it as a favorite. The case sensitivity is then undefined.

What do you think? Thank you.

tidyui commented 3 months ago

I would consider this a bug in the cache lookup, will add this to the next release. As a temporary fix

  1. Make sure all aliases in the database are lower-case
  2. Add a custom middle first in the pipeline that rewrites the incoming url to lowercase and then just passes it on.