Home > Back-end >  X-Robots-Tag not shown in HTTP response header
X-Robots-Tag not shown in HTTP response header

Time:09-18

My sample PDF URL is: enter image description here

Any help on where I am going wrong

CodePudding user response:

<Files "\.pdf$">
  Header set X-Robots-Tag "noindex, nofollow"
</Files>

You have copied the linked solution incorrectly. To match a regex with the Files directive you need the additional ~ argument. ie. <Files ~ "\.pdf$">. (Although the FilesMatch directive is arguably preferable when using a regex.)

However, you do not need a regex here. Just use the standard Files directive with a wildcard (not regex) pattern. For example:

<Files "*.pdf">
:

Reference:

  • Related