Header set Link?

Dave Wreski <[email protected]>
Newsgroups gmane.comp.apache.user
Organization Guardian Digital, Inc.
Message-ID <[email protected]>
Hi,

I'm using httpd-2.4.62 on fedora40 and I would like to dynamically add a 
Canonical Tag to the HTTP Header. I set this in my .htaccess in the 
document root.

SetEnvIf Request_URI "(.+)\.pdf$" PDF_CANONICAL_URL=$1\.pdf
Header add Link "<https://%{HTTP_HOST}e%{REDIRECT_PDF_CANONICAL_URL}e>; 
rel=\"canonical\"" env=REDIRECT_PDF_CANONICAL_URL

However, the %{HTTP_HOST} variable doesn't seem to be set.

Using "curl -I" displays this:
Link: 
<https://(null)/images/joomgallery/details/gallery_2/img-1512_20210924_1725768871.jpg>; 
rel="canonical"

I followed the example here:
https://stackoverflow.com/questions/63768450/howto-add-canonical-tag-to-the-http-headers-for-dynamically-generated-pdf

Can you explain where the REDIRECT_ is defined? According to the info at 
the stackoverflow link above, it appears to be a fixed variable that 
somehow prevents the header above from being duplicated during the 
second pass, but I don't fully understand.

Is this the best way to do it? What if I wanted to move it to my apache 
config instead of .htaccess? I tried moving it into the VirtualHost 
config and it doesn't work. Maybe it's getting lost in the .htaccess 
scanning?

What am I missing?
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.