DEV Community

Discussion on: Making a multilingual site with Next.js - Part 2

Collapse
tachuong20121997 profile image
Chuong Tran • Edited

hi Elves Sousa, i have 2 links like this and both lead to 1 page, what should I do?
path 1: '/:language/:type/:name' ("vi/doctor/balestra")
path 2: '/:type/:name' ("doctor/balestra")
If not, the language will default to "en", please help me, thank you!
i tried using rewrite, but nextjs doesn't accept
dev-to-uploads.s3.amazonaws.com/up...

Collapse
elvessousa profile image
Elves Sousa Author

Hello, Chuong!
I have not worked with rewrites yet, but from what I could understand reading the docs on the subject, you don't need to repeat the parameters in the destination property. So, using the image you posted as a basis, try doing this on your next.config.js:

...
async rewrites() {
    return [
        {
            source: '/:type/:name',
            destination: '/profile/:language'
        },
        {
            source: '/:language/:type/:name',
            destination: '/profile'
        },
        {
            source: '/:language/:type/:name/:clinicId',
            destination: '/profile'
        },
        ...
    ]
},
...
...
Enter fullscreen mode Exit fullscreen mode

See if it works!