Need to rewrite special chars from my old blog URL

Hi,

I would like to rewrite the special chars from my old URL

Remove “:” char and replace all accents chars with non accents chars : “é” => “e” …

Exemple :
Old link from my old blog: https://www.geeek.org/mail-relay-test-%3A-testez-la-sécurité-de-votre-serveur-de-mail2/

New link on Ghost :

Is it possible to integrate JS function in the rewrite.json file ?
Should I modify the Ghost core for that ?
Maybe using NGINX ?

Thank-you in advance,

This is how I would fix it.

  1. Export you ghost.db
  2. Open ghost.db it in a IDE like VS Code
  3. find and replace your links
  4. re-import your ghost.db in Ghost

Done!

1 Like

I would like to keep inbound links … :thinking:

The issue is that my links are rejected by the isSlug control :

validator.extend('isSlug', function isSlug(str) {
    return validator.matches(str, /^[a-z0-9\-_]+$/);
});

I think I found the right place in the uncapitalise.js code. I added the following lines

if (/[!:_éèàùç]/.test(decodedURI)){
    var newPath = decodedURI.replace(/\s/g, '-')
    .replace(/[!:_]/g, '')
    .replace(/[é]/g, 'e')
    .replace(/[è]/g, 'e')
    .replace(/[à]/g, 'a')
    .replace(/[ù]/g, 'u')
    .replace(/[ç]/g, 'c')
    .replace(/[-]{2}/g, '-');

    redirectPath = (localUtils.removeOpenRedirectFromUrl((req.originalUrl || req.url).replace(pathToTest, newPath)));
    return urlService.utils.redirect301(res, redirectPath);
}
next();

Thank-you !