Excel xlsx files downloading as zip file - excel

The following is happening in IE8. The server is Apache2 on Ubuntu.
I'm trying to get an excel file to download via a link. When I click the link the file shows with a .zip extension.
I've set the mime-types in a .htaccess file and also can see they are in the /etc/mime.type file.
The .htaccess file as follows:
AddType application/vnd.ms-word.document.macroEnabled.12 .docm
AddType application/vnd.openxmlformats-officedocument.wordprocessingml.document docx
AddType application/vnd.openxmlformats-officedocument.wordprocessingml.template dotx
AddType application/vnd.ms-powerpoint.template.macroEnabled.12 potm
AddType application/vnd.openxmlformats-officedocument.presentationml.template potx
AddType application/vnd.ms-powerpoint.addin.macroEnabled.12 ppam
AddType application/vnd.ms-powerpoint.slideshow.macroEnabled.12 ppsm
AddType application/vnd.openxmlformats-officedocument.presentationml.slideshow ppsx
AddType application/vnd.ms-powerpoint.presentation.macroEnabled.12 pptm
AddType application/vnd.openxmlformats-officedocument.presentationml.presentation pptx
AddType application/vnd.ms-excel.addin.macroEnabled.12 xlam
AddType application/vnd.ms-excel.sheet.binary.macroEnabled.12 xlsb
AddType application/vnd.ms-excel.sheet.macroEnabled.12 xlsm
AddType application/vnd.openxmlformats-officedocument.spreadsheetml.sheet xlsx
AddType application/vnd.ms-excel.template.macroEnabled.12 xltm
AddType application/vnd.openxmlformats-officedocument.spreadsheetml.template xltx
I've looked a loads of forums some say the leading dot for .docm on the the first line should be added other say not. The Apache documentation say it can include on not include the leading dot. I've tried with both.
I've copied the code to a text editor to make sure there are no hidden characters and pasted it back.
I've cleared the browser cache after each change and restarted Apache. Nothing seems to work.
This did work on our old server so I'm convinced the problem is server configuration.
Any help would be appreciated.

Related

Force all files under the specific path to download (not open in browser) using .htaccess

I know how to force all jpg files to download using .htaccess, like below:
AddType application/octet-stream jpg
But now I want to force all files (no matter what format) under the specific path to download using .htaccess
For example:
Force all files under the path /home/user/public_html/files/attachments to download and not open in browser directly.
How can I do?
You can probably use RewriteRule to reach your goal, no need to use AddType:
RewriteCond %{REQUEST_URI} ^/home/user/public_html/files/attachments/(.*)$ [NC]
RewriteRule ".+\..+" "-" [T=application/octet-stream,L]
This will force any kinds of formats to download in the browser only when the path matches /home/user/public_html/files/attachments.
You can add all the possible extensions which are in the folder to AddType. like,
AddType application/octet-stream .jpg .doc .mov .avi .pdf .xls .mp4
I came across similar situation and couln't able to find a better way of doing it so posting this as answer.
Force a Content-Disposition header.
Header always set Content-Disposition "attachment"

SVG files not working after switching website hosting to my NAS

I'm now hosting my website off my personal NAS drive and everything seems to be working except the SVGs.
I tried adding the .htaccess file with:
AddType image/svg+xml svg svgz
AddEncoding gzip svgz
but they still do not work. When I go to the URL of the file it just shows an error as if the file does not exist.
Any ideas?
Thanks in advance!

Issue with playing some .mp4 on Google Chrome

I have downloaded some .mp4 files from shutterstock to use them in my website project.
Everything works perfect on localhost, i can play the movies like localhost/example.mp4 on every browser. I uploaded the files on my server, but now, it won`t play with Google Chrome (myserver.com/example.mp4), but will play with other browsers. This is very strange.
Anyone have any explanation ?
I checked the mime types in my cPanel account and all are ok, also i added the next code into htaccess but still doesn`t work.
AddType video/ogg .ogv
AddType video/mp4 .mp4
AddType video/mp4 .mov
AddType video/webm .webm
and
<FilesMatch mp4>
Satisfy any
order allow,deny
allow from all
</FilesMatch>
What should be the issue? Is a file issue or an issue from the server? Cues from localhost it will open in Google Chrome.

PHP MIME type application/vnd.wap.xhtml+xml

I have added the following to my .htaccess file
# MIME Types for WAP
AddType text/vnd.wap.wml .wml
AddType image/vnd.wap.wbmp .wbmp
AddType application/vnd.wap.wmlc .wmlc
AddType text/vnd.wap.wmlscript .wmls
AddType application/vnd.wap.wmlscriptc .wmlsc
AddType application/vnd.wap.xhtml+xml .xhtml
However the file is saved as index.php and uses the following header:
header("Content-Type: application/vnd.wap.xhtml+xml");
The file currently tries to download can anyone advise how to rectify this?
Use the XHTML MIME type in addition to the existing mappings:
AddType application/xhtml+xml .xhtml
In addition, AddHandler can be used to handle that content-type.

Drupal MP4 videos not playing in Firefox

I've added these 2 lines to our htaccess file, but the video shows a dark screen with No video with supported MIME type and format found:
AddType sites/default/files/videos/original/webm .webm
AddType sites/default/files/videos/original/mp4 .mp4
sites/default/files/videos/original/webm and sites/default/files/videos/original/mp4 aren't mime-types. You're probably looking for video/webm and video/mp4, respectively.

Resources