Created
March 3, 2014 08:42
-
-
Save tophatsteve/9320858 to your computer and use it in GitHub Desktop.
Force PDFs to always download rather than open in brower
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<system.webServer> | |
<!-- other system.webServer stuff --> | |
<rewrite> | |
<outboundRules> | |
<rule name="Forcing Download for PDFs" preCondition="IsPDF"> | |
<match serverVariable="RESPONSE_Content-Disposition" pattern=".*" /> | |
<conditions> | |
<add input="{REQUEST_FILENAME}" pattern="(.*)\\([^/]+)\.pdf$" /> | |
</conditions> | |
<action type="Rewrite" value="attachment; filename={C:2}.pdf" /> | |
</rule> | |
<preConditions> | |
<preCondition name="IsPDF"> | |
<add input="{REQUEST_FILENAME}" pattern="\.pdf$" /> | |
</preCondition> | |
</preConditions> | |
</outboundRules> | |
</rewrite> | |
<!-- other system.webServer stuff --> | |
</system.webServer> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment