Apache 2.4 set mime type of file without extension

前端 未结 1 886
眼角桃花
眼角桃花 2020-12-31 06:01

I have upgraded from Apache 2.2 to 2.4 on a RedHat 6.4 server and came across an issue with mime types.

Apache has a DefaultType Directive. In Apache 2.2 I set this

相关标签:
1条回答
  • 2020-12-31 06:50

    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”.

    0 讨论(0)
提交回复
热议问题