Epicweb-Optimizely / Epicweb.Optimizely.RedirectManager

This .net 6 library contains a RedirectManager and admin user interface integration in an Optimizely CMS 12 and commerce 14 project. Tested with Alloy.
Apache License 2.0
0 stars 2 forks source link

Automatic Creation of Redirection Rules when Editing Content #2

Closed Pv-Martins closed 8 months ago

Pv-Martins commented 9 months ago

Hi,

I've been using RedirectManager 6.0.0 along with EPiServer.CMS 12.22.5, and I've come across an issue that I'd like some guidance on.

Every time one of our editors saves a page, it seems to create a new redirection rule with the wildcard selected. While this might not be problematic in most cases, it's causing the redirection to the same page with the wildcard when attempting to access a non-existent page. This becomes particularly troublesome when editing the FrontPage. Essentially, it generates redirections with wildcards to the FrontPage, resulting in all non-existent pages being redirected to the FrontPage.

This behavior prevents us from displaying the 404 page for non-existent links. Moreover, it's generating multiple duplicate rules, cluttering the setup unnecessarily.

image

I'm reaching out to see if there's a specific configuration setting that I might be overlooking or using incorrectly. Alternatively, I'd appreciate any guidance on the best approach to resolve this issue.

Thank you in advance for your assistance.

LucGosso commented 9 months ago

Strange this is

can you test to reproduce it in your dev env, this code: https://github.com/Epicweb-Optimizely/Epicweb.Optimizely.RedirectManager/blob/62168d22ee56b136a9067fb930061311325188e5/Epicweb.Optimizely.RedirectManager/RedirectKeeper.cs#L45

I guess in your environment the UrlSegment has changed, but why ... maybe some lang configuration in website ...

Please look further and come back with your findings.

Pv-Martins commented 9 months ago

Alright, I've figured out what's happening. Let me use an example from a test I ran using the Alloy example with RedirectManager from the project:

There's a StartPage with languages EN and SV, both pages having the urlSegment as "start", and the English page is set as MasterLanguage. Now consider that I change one UrlSegment to "startEN" and the other to "startSV". image image

Any changes I make on the SV page will compare the data of the English page obtained at line 43, in the GetLastVersion() method, because it searches for the MasterLanguage. When the comparison of oldPage.URLSegment != e.Content.URLSegment is made, it will be different, as the oldPage value will be "startEN" and the current Content's will be "startSV". image

Since it identifies them as different, it registers again in RedirectManager and keeps recording for each change made. Now, my question is whether this is an expected behavior and what would be the reason. Is the standard behavior not to use different urlSegments for the same page in different languages? And if the client wishes to continue using this, do you have any idea how I can solve the problem?

I made some quick tests, and it seems that changing from MasterLanguage to Language works the way I expected, but I'm not sure if I'm overlooking any information. https://github.com/Epicweb-Optimizely/Epicweb.Optimizely.RedirectManager/blob/62168d22ee56b136a9067fb930061311325188e5/Epicweb.Optimizely.RedirectManager/RedirectKeeper.cs#L43

LucGosso commented 8 months ago

Hello, sorry for late answer. No it seems to be wrong in this code row 43. Why would it always compare with MasterLang, it does not make since. Should be CurrentCulture.

Dont know when I can manage this change . You could do your own implementation of RedirectKeeper, send me the code, or make a PR with the changed code.

Pv-Martins commented 8 months ago

Hi, I apologize for my really delayed response. I created a pull request regarding the error fix, as I did in my local project. You can find it at the following link: https://github.com/Epicweb-Optimizely/Epicweb.Optimizely.RedirectManager/pull/3

LucGosso commented 8 months ago

Thank you for your contribution, version 6.2 will be out today.