Reputation: 11
Client has a website that makes heavy use of pdfs, and certain parts of the site depend on the pdfs loading in the browser.
Users browsing in google chrome, however, occasionally cannot view the pdfs.
The issue may be inherent in wordpress, as note here: https://wordpress.org/support/topic/pdf-files-and-chrome
In the meantime, I would like to add the following condition to .htaccess:
If browser is chrome
then Set MIMEtype to octet stream
This will at least allow unfortunate users to download view the pdfs, rather than loading screens.
From research, I note that the browser can be detected via .htaccess using RewriteCond like so:
RewriteCond %{HTTP_USER_AGENT} Chrome
But
ForceType application/octet-stream
seems to be the only way to the adjust the MIMEtype.
Is there a simple way to do this that I'm overlooking?
Upvotes: 1
Views: 78
Reputation: 143886
No, probably not unless you're using apache 2.4 and utilizing the <If env>
containers. You can use SetEnvIf
to set an environment variable based on the user agent, but without the <If>
containers in 2.4, you can't conditionally call ForceType
.
You may need to force the type in a script or something and route direct file access through that script.
Upvotes: 1