URL Slugs: Redirects or 404s?
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 r开发者_StackOverflow社区edirecting in case of a mismatch)?
-or-
- return a 404, since technically
example.com/123/this-article-s-u-x
doesn't exist?
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.
精彩评论