Rename page folder without breaking http links

Sometimes I need to rename the folder name to match changes made to the page title. But when I do it if we have already shared the page to social network for example, the feature image is broken.

Detailled example

I have the page https://www.koweb.fr/outils-libres in the folder /user/pages/05.outils-libres. I want to rename to https://www.koweb.fr/outils-libres-pour-collaborer. So, I rename the folder and I create a redirection in site.yaml :

redirects:
    /outils-libres(.*): '/outils-libres-pour-collaborer$1'

But the page published two months ago on social netword, newsletter, … and the feature image was https://www.koweb.fr/user/pages/05.outils-libres/01.outils-libres-kit-formations.jpg. The link is now broken.

So I have created a workaround. I copy images of a folder renamed to user/images/archives and I have added redirection in .htaccess file:

RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^user/pages/.+/(.+\.(jpg|png|jpeg|gif)) /user/images/archives/$1 [L,R=301]

But you may have a better solution ?

Another way is to duplicate the page, unpublish the old one and edit the new one. But in the admin interface the old one is always shown. How can I remove page without deleting files and folder ?

At least for FB you can invalidate shared content with FB debugger and Image should get the correct URL then. Maybe some other services also have something similar. Not sure what’s the best way for newsletter - probably a redirect :thinking:

But social network aren’t the only system using the feature image and it’s impossible to remember all shares. And it’s complicated to manage redirection. All editors are not developpers.

The best solution would be a deletion of the page from the admin UI without removing files.