简体   繁体   English

如何将规范标头设置为HTTP响应?

[英]How do I set the canonical header to a HTTP response?

I know that I can add a tag to the html head 我知道我可以在html头中添加标签

<link rel="canonical" href="https://geoffkenyon.com/how-to-add-canonical-tag-to-http-headers">

But I want to add this information in a HTTP response header instead. 但我想将此信息添加到HTTP响应标头中。 What header key and value would the above tag translate to? 上面的标签将转换为什么标头键和值?

I plan to do this in nginx as: 我打算在Nginx中这样做:

location /old-link {
    add_header key value;
}

This adds a header successfully. 这将成功添加标题。 I haven't yet validated that google and others understand it. 我尚未验证Google和其他人是否理解它。

location /docs-test/Otii_Tech_Spec.pdf {
    add_header Link '< href=https://geoffkenyon.com/how-to-add-canonical-tag-to-http-headers >; rel=\"canonical\"';
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在HTTP响应中设置标头? - How to set a header in an HTTP response? 如何设置IBM HTTP Server的响应标头 - how can I set the response header for IBM HTTP Server 使用PHP / Apache剥离Canonical Link HTTP响应标头 - Canonical Link HTTP Response Header being stripped using PHP / Apache 如何在 HTTP 标头中设置 REMOTE_USER? - How do I set REMOTE_USER in a HTTP header? 服务器如何设置HTTP响应头? - How do servers set HTTP response headers? 如何使用 POST 请求的响应标头发出新的 GET 请求? 颤振/飞镖/HTTP - How do I use the response header from a POST request to make a new GET request? Flutter/Dart/HTTP 如果HTTP响应没有Content-Length标头,如何停止从套接字读取? - How do I stop reading from a socket if the HTTP response doesn't have a Content-Length header? 如何为HTML文档请求的JS和CSS文件设置http&#39;accept&#39;标头? - How do I set the http 'accept' header for JS and CSS files requested by an HTML document? 如何设置HTTP调用和响应? - How do I setup an HTTP call and response? 如何在Node.js中使用相同的密钥设置多个http头字段? - How do I set multiple http header fields with the same key in Node.js?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM