Apache 显示 MP4 文件的内容而不是下载提示 [英] Apache shows the contents of MP4 file rather than a download prompt

查看:25
本文介绍了Apache 显示 MP4 文件的内容而不是下载提示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 Linux 上运行 Apache,当我转到一个 .mp4 文件的 url 而不是让我下载文件时,它会显示文件的内容(作为损坏的文本)

I am running Apache on Linux, and when I go to a url that is a .mp4 file rather than let me download the file it shows the contents of the file (as mangled text)

例如输出是

ftypisom isomiso2avc1mp41 *moov lmvhd ̴ d̴ d@Htrak \tkhd ̴ d̴ d@ $edts elstmdia mdhd ̴ d̴ d-hdlr 视频 VideoHandler kmminf vmhd

��� ftypisom���isomiso2avc1mp41��*moov���lmvhd����̴�d̴�d��������������������������������������������������@��������������������������������Htrak���\tkhd���̴�d̴�d��������������������������������������������������������@������������$edts���elst��������������������mdia��� mdhd����̴�d̴�d���� ��������-hdlr��������vide������������VideoHandler���kminf���vmhd��������������

如何让 Apache 正确地提供服务?

How do I make Apache serve it correctly?

推荐答案

添加 AddType 指令:

AddType video/mp4 .mp4

这将导致 Apache 将正确的标头发送到您的浏览器,然后浏览器将选择正确的方法来下载或播放媒体文件.

This will cause Apache to send the correct headers to your browser, which will then select the correct method to download or play the media file.

确保您安装并激活了 mod_mime(但我认为这是默认设置;我从来没有遇到过任何问题).

Make sure you have mod_mime installed and activated (but I reckon it is by default; I never had any issues with this).

更多信息在这里:http://httpd.apache.org/docs/2.2/mod/mod_mime.html

这篇关于Apache 显示 MP4 文件的内容而不是下载提示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆