在Internet Explorer中强制PDF下载“仅” [英] Force PDF download 'only' in Internet Explorer
问题描述
我在IE中显示PDF文档时遇到了问题。其他浏览器(Chrome,Firefox等)都可以,但IE并不好。因此,我的解决方案是仅对IE用户强制进行PDF下载,同时修改.htaccess文件。我目前设置强制所有浏览器下载PDF,但我想要chrome / firefox /等。用户将PDF显示在浏览器中。
I've been having issues with displaying PDF documents in IE. Other browsers (Chrome, firefox, etc.) are all OK but IE is no good. So my solution is to force the PDF download for IE users ONLY with modifications to the .htaccess file. I have it currently set up to force the PDF download on all browsers, however I want chrome/firefox/etc. users to have the PDF displayed in browser.
这是我当前的.htaccess规则:
Here is my current .htaccess rules:
<FilesMatch "\.(?i:pdf)$">
SetEnvIf Request_URI "\.pdf$" requested_pdf=pdf
Header add Content-Disposition "attachment" env=requested_pdf
</FilesMatch>
有没有办法利用 BrowserMatch
来在IE中只设置此标头?或者是否有另一种方法使用另一种方法?到目前为止,我没有运气。
Is there a way to utilize BrowserMatch
to only set this header when in IE? Or is there another solution using another method? I've had no luck so far.
提前谢谢!
CentOS | Apache | PHP
CentOS | Apache | PHP
推荐答案
在你的.htaccess文件中试试这个
Try this in your .htaccess file
SetEnvIf Request_URI .pdf $requested_pdf = pdf
SetEnvIf Request_URI ".pdf$" requested_pdf=pdf
标题添加内容处置附件env = requested_pdf
Header add Content-Disposition "attachment" env=requested_pdf
这篇关于在Internet Explorer中强制PDF下载“仅”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!