开发者

How widely supported are scheme-relative URIs in HTTP 301 redirects

I want to have requests for the www subdomain or for alternate top-level domains redirected to one canonical URL.

To avoid HTTP/HTTPS issues, I figured the easiest way would be to just send a scheme-relative URI in the Location header, like so:

HTTP/1.1 301 Moved Permanently
Location: //example.com/

This seems to work fine in browsers, but the toy »validator« at http://no-www.org/ does not handle it correctly. Is this just a single badly written script, or is this behavior actually more common in scripts, 开发者_JS百科crawlers, etc. out there?


Location expects an absolute URI:

[…] The field value consists of a single absolute URI.

Location       = "Location" ":" absoluteURI

Although most user agents will also accept relative URIs, you should stick to the specification and provide an absolute URI.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜