Question

Some sites, like here at SO, allow 'bogus' slugs in the URL. Before implementing URL slugs on my site, I have a question of 'best practices'...

Given a structure like example.com/123/article-slug-here/, if my site allows bogus slugs by querying on the ID -

Should I ...

  • just do a redirect to the appropriate/canonical URL (verifying the slug, and redirecting in case of a mismatch)?

-or-

  • return a 404, since technically example.com/123/this-article-s-u-x doesn't exist?
Was it helpful?

Solution

Neither. Leave it as it is. Google will figure out the canonical url and keep them in their index.

You could do redirect (301 Moved Permanently of course) only if you wish to punch Google to update the changed url in their index more quickly. If it's not important, no need to bother.

P.S. I basically did the same thing in my blog. Once I changed the title of some entry and after a while (a few weeks) Google updated their index in accordance to the new canonical url that was specified in the page. Simple and works.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top