PHP旨在作为CSS,但充当MIME类型text/html [英] PHP intended as css but served as MIME type text/html

查看:90
本文介绍了PHP旨在作为CSS,但充当MIME类型text/html的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在网页中有一些表格.表单由CMS组件生成.表单的样式是通过template_css.php文件设置的,该文件有助于在给定表单变量的情况下进行动态样式设计.

I have some forms in webpage. The forms are generated by a CMS component. The styling of the forms is set through a template_css.php file, which facilitates the dynamic styling given a form's variables.

在我的本地环境中,文件加载正常,并且css呈现了预期的效果.但是在公共服务器上,css无法呈现,我从Chrome调试器收到以下警告:

In my local environment, the file is loaded fine, and the css renders as expected. But in public server, the css is not rendered and I get the following warning from Chrome debugger:

资源被解释为样式表,但以MIME类型text/html传输:... filepath

Resource interpreted as Stylesheet but transferred with MIME type text/html: ...filepath

即使是PHP文件,我该怎么做才能强制将此文件读取为CSS?

What can I do to force this file to be read as CSS even though is a PHP file?

谢谢

推荐答案

您要将标题设置为text/css:

You want to set the header to text/css:

<?php header("Content-type: text/css"); ?>

这篇关于PHP旨在作为CSS,但充当MIME类型text/html的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆