我遇到了PHP的mime_content_type这个怪异的问题,除了CSS和JavaScript文件外,它都能正常工作(CSS的默认mime设置为text / html),但CSS和JavaScript文件除外。
修改mime.types文件似乎没有什么区别(它在httpd.conf上的路径正确)。
例子
<?php
echo(mime_content_type('index.html')); // returns text/html
echo(mime_content_type('default.png')); // returns image/png
echo(mime_content_type('bootstrap.min.js')); // returns text/plain
echo(mime_content_type('css/animate.css')); // returns text/plain
echo(mime_content_type('css/style.css')); // returns text/x-asm
?>
Run Code Online (Sandbox Code Playgroud)
在完全相同的Apache安装上提供的完全相同的文件会在其Content-Type
标头上正确标记,这几乎就像PHP在使用其mime检测机制一样。
我使用Wamp 3.0.6 64-bit
和内置PHP 7.0.10
上Windows 10 64-bit build 15063.483 mod_mime and mode_mime_magic
被启用。