Apache 2.4 set mime type of file without extension

冷暖自知 提交于 2019-12-03 05:55:55
Michael Allan

Extensionless files only

This solution affects only extensionless, statically served files: (credit Eugene Kerner)

<FilesMatch "^[^.]+$">
    ForceType text/plain
    </FilesMatch>

Any unknown content

This one affects any response that would otherwise be transmitted without a Content-Type header. In other words, it mimics the behaviour of the old DefaultType directive:

Header set Content-Type "text/plain" "expr=-z %{CONTENT_TYPE}"

It should be possible to use setifempty here instead of the -z expression. But it fails and overwrites the header in every response, empty or not. I don’t know why. Eric Covener says it’s because the Content-Type header isn’t added “until the very last second”.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!