Adding "Link" Header

To avoid SEO issues on my subdomains, I need to add a “Link” header to
support Google’s canonical header. The format is as follows (from
http://googlewebmastercentral.blogspot.com/2011/06/supporting-relcanonical-http-headers.html):

Link: http://www.example.com/white-paper.html; rel=“canonical”

So, the add_header command would need to reference $uri, but it also
needs a semi-colon and double quotes. How can I add this header to my
config?

Posted at Nginx Forum:
http://forum.nginx.org/read.php?2,222185,222185#msg-222185

On 9 Fev 2012 22h43 WET, [email protected] wrote:

To avoid SEO issues on my subdomains, I need to add a “Link” header
to support Google’s canonical header. The format is as follows
(from

http://googlewebmastercentral.blogspot.com/2011/06/supporting-relcanonical-http-headers.html):

Link: http://www.example.com/white-paper.html; rel=“canonical”

So, the add_header command would need to reference $uri, but it also
needs a semi-colon and double quotes. How can I add this header to
my config?

add_header Link “<$scheme://$http_host$request_uri>; rel=“canonical””;

— appa

10 февраля 2012, 02:44 от “jwilson” [email protected]:

To avoid SEO issues on my subdomains, I need to add a “Link” header to
support Google’s canonical header. The format is as follows (from

http://googlewebmastercentral.blogspot.com/2011/06/supporting-relcanonical-http-headers.html):

Link: http://www.example.com/white-paper.html; rel=“canonical”

So, the add_header command would need to reference $uri, but it also
needs a semi-colon and double quotes. How can I add this header to my
config?

location ~* ^/(.*)(.pdf)$ {
add_header Link “<$scheme://$host:$server_port/$1.html>;
rel=“canonical””;
}

You can use $http_host instead of $host:$server_port, but if you get
a request without the Host header, $http_host will be empty.

Max

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs