我正在尝试使用 PHP 输出 CSS 以通过 wordpress 设置使其更加动态,但我收到 500 内部服务器错误。 我将 header 设置为 text/css,尝试在 IIS 中添加处理程序,但它似乎不起作用。 PHP 文件中没有错误,因为如果我删除我的代码,它不会改变。
<?php header("Content-type: text/css"); ?>
而在 apache 服务器的情况下,将以下内容添加到 .htaccess 是有效的
AddType application/x-httpd-php .html .htm .css
AddHandler application/x-httpd-php .html .htm .css
这是我使用 IIS 得到的响应:
HTTP/1.1 500 Internal Server Error
Content-Type: text/css
Server: Microsoft-IIS/7.0
X-Powered-By: PHP/5.3.13
Date: Tue, 11 Sep 2012 16:38:12 GMT
Content-Length: 0
知道如何让它在 IIS 下工作吗?
最佳答案
该问题可能与 IIS 7 配置问题有关
从 Windows 添加和删除程序配置 IIS 时,确保在通用 HTTP 功能中启用静态内容
- IIS 7 Not Serving Static Files .另一个引用 - Funny Problem: Windows 7, IIS 7.5: Images, CSS not showing!
或者尝试 Wildcard script mapping and IIS 7 integrated pipeline或者只是简单地重新安装 IIS。
关于php - 在 PHP 文件中提供 CSS(使用 IIS),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12373965/