Hi,
I tried this solution and it works but when the page is multilanguage I have a problem. I’ll show an example:
A new with this url (https://mysite.site/es/news/category/new) can change with the code you said me (https://mysite.site/es/news/new)
But when my page is setted to French https://mysite.site/fr/news/category/new it doesn’t run, 404 page appears. I think the problem is the name of the category that in french changes.
I wrote your code for each language that has my page and the only language that doesn’t run is french (the other ones are variations of Spanish and the names of the categories don’t change)