
私の Apache サーバーには、いくつかの docx、xlsx、pptx ファイルが保存されています。
一部のクライアント ブラウザーは、これらを通常の zip ファイルと認識し、ダウンロード時にファイル拡張子を変更します。これを行わないようにするにはどうすればよいですか。
(Ubuntu サーバーを使用)
答え1
ファイルは実際にはXML文書のZIPです。これをApacheの.htaccessに追加してください。
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
サーバーには新しい ms ファイル タイプ用の適切な MIME タイプが設定されていません
/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: UbuntuとDebianのApacheは/etc/mime.typesから読み取ります