
На моем сервере Apache я храню несколько файлов docx, xlsx pptx.
Некоторые клиентские браузеры думают, что это обычные zip-файлы и меняют расширение файла при загрузке. Как сделать так, чтобы он больше так не делал.
(Используя сервер Ubuntu)
решение1
Файлы на самом деле являются ZIP-файлами XML-документов. Добавьте это в ваш .htaccess в Apache
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
решение2
На сервере не настроены правильные типы MIME для новых типов файлов MS.
Добавьте следующее в файл /etc/mime.types и перезапустите Apache, проблема должна быть устранена.
# Added by myname 2009-06-03
application/vnd.ms-word.document.macroEnabled.12 docm
application/vnd.openxmlformats-officedocument.wordprocessingml.document docx
application/vnd.openxmlformats-officedocument.wordprocessingml.template dotx
application/vnd.ms-powerpoint.template.macroEnabled.12 potm
application/vnd.openxmlformats-officedocument.presentationml.template potx
application/vnd.ms-powerpoint.addin.macroEnabled.12 ppam
application/vnd.ms-powerpoint.slideshow.macroEnabled.12 ppsm
application/vnd.openxmlformats-officedocument.presentationml.slideshow ppsx
application/vnd.ms-powerpoint.presentation.macroEnabled.12 pptm
application/vnd.openxmlformats-officedocument.presentationml.presentation pptx
application/vnd.ms-excel.addin.macroEnabled.12 xlam
application/vnd.ms-excel.sheet.binary.macroEnabled.12 xlsb
application/vnd.ms-excel.sheet.macroEnabled.12 xlsm
application/vnd.openxmlformats-officedocument.spreadsheetml.sheet xlsx
application/vnd.ms-excel.template.macroEnabled.12 xltm
application/vnd.openxmlformats-officedocument.spreadsheetml.template xltx
http://www.webdeveloper.com/forum/showthread.php?t=162526имеет информацию об этой проблеме
решение3
Похоже, ваш веб-сервер просматривает магические числа внутри этих файлов и видит, что это ZIP-файлы.
Посмотри на:http://www.webdeveloper.com/forum/showthread.php?t=162526
решение4
Скачатьhttp://packages.ubuntu.com/oneiric/mime-support, и установите его с помощью dpkg -i. Работает отлично!
PS: Apache в Ubuntu и Debian читает из /etc/mime.types