Written by The Jahia Team
 
Developers
   Estimated reading time:

How to add http header in http response when a user download a file

Answer

This can be done with a rewrite rule. For example, the following rule would add the header X-Robots-Tag to any url matching pdf

    <rule>
        <name>Set header for pdf files</name>
        <note>rule to set noindex</note>
        <from>^(.*)(pdf)$</from>
        <set type="response-header" name="X-Robots-Tag">noindex</set>
    </rule>

The rule can be customized to work with files of other types, or files from a specific site or path.

Related links