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 ?