Apache2 服务器 MIME 类型

问题描述:

我试图让我的 Apache2 Web 应用程序在浏览器指向时将任意文件扩展名作为八位字节流推送.

I am trying to get my Apache2 web application to push an arbitrary file extension as an octet-stream when pointed to by a browser.

即有人去 blahblah/examples/example1.xyz 我希望浏览器下载 .xyz 文件而不是仅仅显示它.

i.e. Someone goes to blahblah/examples/example1.xyz I want the browser to download the .xyz file rather than just display it.

我尝试在网络应用程序的根目录中添加 .htaccess,包括

I have tried adding .htaccess in the root of the web app including

AddType application/octet-stream xyz

而且我还尝试将 mime 类型添加到 /etc/apache2/mods-enabled/mime.conf/etc/mime.types 被引用作为 mime.conf 中的类型库.

And I have also tried to add the mime type to /etc/apache2/mods-enabled/mime.conf and /etc/mime.types which is referenced as the types library from mime.conf.

我已经在互联网上阅读了很多关于此的内容,但仍然没有得到解决.任何帮助将不胜感激!谢谢.

I have read a good deal about this on the internet and still haven't gotten this working. Any help would be greatly appreciated! Thanks.

我相信你必须在扩展前添加一个.:

I believe you have to add a . before the extension:

AddType application/octet-stream .xyz