Links on the website I am making currently look like this:
My php system pulls out the id (
151 say) and uses that to pull to content from my database. The text afterwards is effectively ignored (much like stackoverflow uses).
Now my problem is that this creates duplicate titles that Google will sometimes index and I lose SEO as a result:
What is the best way to make it so that google and other search engines only see the correct full link so that I don’t end up with duplicates and get the best ranking possible?
EDIT: I notice that with stackoverflow site that you get dynamically redirected to another page? How do they do that?
Pick a URI to be canonical.
When you get a request for
http://example.com/123/anything then, instead of ignoring the
anything, compare it to the canonical URI.
If it doesn’t match, issue a
301 Moved Permanently redirect.
A less optimal approach would be to specify the canonical URI in the page instead of redirecting:
<link rel="canonical" href="http://example.com/123/anything"/>