替代PHP的头功能功能、PHP

2023-09-02 00:21:57 作者:给我个怀抱

我工作的一个网站,有很多样式表所有这一切都需要处理的PHP脚本服务器端。我的的的.htaccess 的文件看起来是这样的:

I'm working on a website that has a number of style sheets all of which need to be handled as PHP scripts server-side. My .htaccess file looks something like this:

<FilesMatch ".(css)$">
    ForceType application/x-httpd-php
</FilesMatch>

这会导致一个小问题,因为HTTP响应的内容类型的MIME类型字段,然后设置为的text / html 而不是文/ CSS

This causes a small problem as the mime type of the http-response's Content-Type field is then set to text/html instead of text/css.

很明显,我可以通过添加标题(文/ CSS的Content-Type)解决这一问题?

Obviously I can fix this by adding header('Content-Type: text/css') to all of my files but is there a better way?

我能做到这一点从.htaccess文件中?没有通过所提供的指令的 mod_mime 的或 mod_negotiation模块 的似乎就是我寻找。

Can I do this from within the .htaccess file? None of the directives offered by mod_mime or mod_negotiation seem to be what I'm looking for.

推荐答案

尝试:

php_value default_mimetype "text/css"