Muckeypuck
Muckeypuck

Reputation: 559

rewrite rule for canonical link to pdf

I am trying to set a canonical link for a pdf file using rewrite 2.0. Is this possible?

<rewrite>
  <rules>
    <rule name="Returnable Crate PDF" stopProcessing="true">
      <match url="/returnablecrates/Crate_FAQs.pdf" />
      <action type="Rewrite" url="https://www.somecompany.com/ rel="canonical" />
    </rule>
  </rules>
</rewrite>

Upvotes: 1

Views: 745

Answers (1)

Cynthia A Lockley
Cynthia A Lockley

Reputation: 110

From Google Search Engine Console:

rel=canonical tag Only works for HTML pages, not for files such as PDF. In such cases, you can use the rel=canonical HTTP header.

One solution I know of --see the accepted answer for how to handle PDF and image files using a canonical header .php file. Canonical Header Links for PDF and Image files in .htaccess

Upvotes: 1

Related Questions