Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AutomaticRedirectsEnabled setting set to false still create redirects for moved/renamed pages #130

Open
efraimlorenzana opened this issue Sep 4, 2024 · 7 comments

Comments

@efraimlorenzana
Copy link

Hi there,

I'm using this package to handle NotFound redirects in our Optimizely CMS project. I’ve run into an issue where setting "AutomaticRedirectsEnabled" to false doesn’t seem to stop redirects from being created when I move or rename a page.

What I have in the configuration:
services.AddOptimizelyNotFoundHandler(o =>
{
o.AutomaticRedirectsEnabled = false;
});

What I Expected:
No automatic redirects should be created when AutomaticRedirectsEnabled is set to false.

What Actually Happened:
Redirects are still being created automatically even though I’ve disabled that feature.

Environment:
Optimizely CMS Version: 12.30.0
Geta.NotFoundHandler.Optimizely Version: 5.0.8
.NET Core Version: net6.0

I’ve double-checked the documentation, and it seems like this should be working, so I’m not sure what’s going wrong. Any chance you could take a look?

Thanks!

@jevgenijsp
Copy link
Contributor

Yes, this should work.
Maybe you left this flag enabled from the appsettings.json? And that's why it gets overwritten.

  "Geta": {
    "NotFoundHandler": {
      "Optimizely": {
        "AutomaticRedirectsEnabled":  true
      }
    }
  }

@efraimlorenzana
Copy link
Author

efraimlorenzana commented Nov 4, 2024

Hello,

No we never add this settings in our appsettings.json file, we have configured it via services as below:

services.AddOptimizelyNotFoundHandler(o =>
{
o.AutomaticRedirectsEnabled = false;
});

@jevgenijsp
Copy link
Contributor

I checked in the sandbox app, and the move event stops firing if AutomaticRedirectsEnabled is set to false.

Could you also check whether a record is always created in the ContentUrlHistory table when content is moved?

I suggest also disabling the following two jobs that are related to Automatic Redirects:

  • [Geta NotFoundHandler] Index Content URLs
  • [Geta NotFoundHandler] Register Content Move Redirects

@efraimlorenzana
Copy link
Author

efraimlorenzana commented Nov 4, 2024

Hello, as per checking, the two scheduled jobs are not running automatically either, and no the content that was moved are not created in the ContentUrlHistory. I can reproduce the issue both in my local project and also in live environment.

@jevgenijsp
Copy link
Contributor

Thank you for testing and providing information.

Here’s how automatic redirects actually work:

When content is moved, a record is created in the ContentUrlHistory table. A job or background service then checks the records in this table to generate redirects.

Maybe we are talking about different things? From your previous comment, it seems that ContentUrlHistory wasn’t affected. How did you identify that the problem exists?

@efraimlorenzana
Copy link
Author

Let me share my perspective on how the issue appears from my end. When I create a new page (e.g., /wecare), it is saved in the ContentUrlHistory table with the following information: [{"Url":"/we-care/","Type":"Primary","Language":"en-GB"}].

If I then rename the page to /we-care-2 and check the NotFound Handler Redirects, I notice that a new entry is automatically created for this URL (Old URL: https://jderetail-test-whitelabel.jdecoffee.net/we-care/ & New URL: https://jderetail-test-whitelabel.jdecoffee.net/we-care-2/). Since AutomaticRedirectsEnabled is set to false, I wouldn’t expect redirects to be created automatically for any renamed URL, but that seems to be happening here.

Additionally, when I check the database, I don’t see any data reflecting /we-care-2; only the original entry from when the page was first created is present: [{"Url":"/we-care/","Type":"Primary","Language":"en-GB"}].

Given this outcome, do you think we might be looking at the issue from different perspectives?

@jevgenijsp
Copy link
Contributor

Based on the previous comment, it appears that the AutomaticRedirectsEnabled flag is set to enabled. I don't have any other ideas at the moment.

You could try replicating this issue in the sandbox app included in the package, or debug the initialization of Geta.NotFoundHandler.Optimizely.Core.AutomaticRedirects.ContentUrlHistoryEvents in your solution to check if the events are being registered.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants