DEV Community

Trương Đình Chiến
Trương Đình Chiến

Posted on

How make redirect link like dev.to

I want to build a blog by nextjs and strapi like dev.to.But i have a problem with slug not have an idea to fix it.
With each article, I will create the path with the syntax: https://domain.com/username/slug (it like dev.to).

But a problem , when the user change username, the path will be changed together, this time new url will be:

So I want if users visit the old URL it be auto-redirect to the new url.
At dev.to, I noticed every time change username then path field auto changed (i check by https://dev.to/api/articles)

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!

Top comments (0)