Question

I have set up pretty urls on a site so that this:

http://usafarmtrader.com/viewpost.php?id=4212

Can be viewed like this:

http://usafarmtrader.com/posts/kemp-tx/hale-2-horse-trailer-4212.htm

However, even when I search for the entire friendly url, google says no document matched

How can I fix that?

Here's the current rewrite in my .htaccess:

RewriteRule ^posts/[^/]+/[^.]+-([0-9]+)\.html?$ /viewpost.php?id=$1 [L,NC]
Était-ce utile?

La solution

Google recommends that you specify the preferred URL for content, by adding a link of type "canonical" in the head of your page, e.g.:

<link rel="canonical" href="http://usafarmtrader.com/posts/kemp-tx/hale-2-horse-trailer-4212.htm" />

Google will then treat all variants of the URLs it uses to get there to treat it as a single page. (Of course other search engine providers do exist, and also take note of this)

Autres conseils

Google indexes URL's against a ton of metadata, it isn't a database of URL's you can lookup. Take this random url from an ebay listing: http://www.ebay.co.uk/itm/HALFORDS-12-TORQUE-WRENCH-40200-NM-30150-LB-new-but-no-case-RRP7499-/321205232394 , its not on google either, however it will be there very shortly as ive just posted it on stackoverflow

similarly the url you posted will now show up in google results (or will very soon), as it has been found on stackoverflow. The result will still point to stackoverflow though.

To test your URLs, you need to search for content that would make google provide your URL as a valid result, and hope google has indexed your site already (recent changes might not appear). You can help direct google around your website via a sitemap.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top