riasvdv / statamic-redirect

Redirect allows you to redirect legacy URLs, so that you don't lose SEO value when rebuilding & restructuring a website.
https://statamic.com/addons/rias/redirect
19 stars 21 forks source link

Redirects created when non-published entries have slug change #177

Closed cstilstra closed 5 months ago

cstilstra commented 5 months ago

I think that perhaps it is better if redirects are only created in response to published entries being saved. Because the check to remove conflicting redirects only happens if the entry is published, this can lead to a situation where circular redirects are possible (though they would have no effect since no 404 would be generated). It seems to me that it would be better coding practice and less surprising behavior for developers if the logic to create a redirect on entry change and the logic to remove conflicting redirects were the same (ie: both either do or don't care about whether the entry is published).

To repro:

  1. create an entry that is not published
  2. edit the entry and change the slug
  3. notice that a redirect from old_slug to new_slug will have been created
  4. edit the entry again and change the slug back to the old slug
  5. notice that a redirect from new_slug to old_slug now exists alongside the redirect from old_slug to new_slug
riasvdv commented 5 months ago

Should be fixed in 3.7.1!