简体   繁体   中英

Canonical URLs for REST resources

With plain-old webpages, if you have duplicate content in two locations, you can flag one as 'canonical' so web crawlers and such know that this is just another reference to a resource and explicitly defines the URL of the 'true' location for the content. This is done by using a link tag in the HTML <head> tags of the non-canonical page pointing to the original.

<link rel="canonical" href="http://www.example.com/the-real-url-of-this-content.php>

In the realm of RESTful web services:

  1. Is this needed, recommended, or not advisable to do?
  2. Is Canonical only a construct for HTML to flag content for search engines?
  3. If needed, how is the same accomplished with HTTP headers? I'm not return HTML (just a JSON object) so the link tag makes no sense...
  4. Does it matter whether or not there is more than one URLs for a unique resource in REST

RFC 6596 potentially answers this.

  1. Hard to say.
  2. It's a generic link relation, but it has been "invented" by Google.
  3. See the spec (you could use the HTTP "Link" header field as well).
  4. No, it does not matter; but avoiding multiple URIs for the same thing of course is a good idea no matter what.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM