How can redirect old link to new link after user edited

I want to build a blog by next and strapi like i have a problem with slug not have an idea to fix it.
With each article, I will create the path with the syntax: (it like
Example of Easy user authentication with Next.js - DEV Community
But a problem , when the user change username, the path will be changed together, this time new url will be:

  • Old: https:// domain[.]com/username/slug
  • New: https:// domain[.]com/new_username/slug

So I want if users visit the old URL it be auto-redirect to the new url.
How can do it? how can a designer database in this case?
I no experience about this.I hope will be a little bit suggest from everybody. Thanks!

did you got any solution?

Yes, I find a solution…i will add url every time request to get a article.
I will be set article.url = domain+article.user.username+article.slug to response…it will always be update

Thanks trangchongcheng !

1 Like

Hi @trangchongcheng, I’m fresher in strapi, can you please explain in detail? It’s really appreciated.

I guess the solution would be to also add article id to url and then when loading the page only load article by id and ignore the slug, such as

I would prefer to just have but I don’t have a good idea how to implement redirects in case slug changes.