Next.js Discord

Discord Forum

How to hide dynamic routes from URLs

Unanswered
Broad-snouted Caiman posted this in #help-forum
Open in Discord
Broad-snouted CaimanOP
Hello everyone 🙂

My SEO wants me to remove the dynamic routes from the URLs.
For example, instead of this:
https://www.smartphone-id.com/resources-utiles/categorie/carte-vitale/photo-carte-vitale
She just wants this (the article slug):
https://www.smartphone-id.com/photo-carte-vitale

I don’t know how to do it in a best practice.

4 Replies

you could setup redirects but it will still send user to the long url
you can use rewrites
Cory's Shearwater
https://www.smartphone-id.com/resources-utiles/categorie/carte-vitale/photo-carte-vitale <--- you have few options you make a slug with at root of app dir

app/[slug].tsx => and your slug should be unique across all products being sold on your website
or you can perform redirect however you should also be vary of canonical urls
if your main goal is to make the /[slug] to be the primary place to access the product then you should make that your canonical url