doucuodan0897 2013-08-07 17:51
浏览 247

将CSS文件解析为PHP

So, I moved into a new host. I was using some code in my htaccess to parse css files as PHP. But in this new host, it didn't work. I googled and googled and tried every code I find. All single of them didn't work. Here's some of codes I've tried:

AddHandler application/x-httpd-php .css
AddHandler application/x-httpd-php5 .css
AddHandler application/x-httpd-php53 .css
AddType application/x-httpd-php .css

My PHP version is 5.3.22 and my webhost is using Linux. But they all didn't work. Please help.

  • 写回答

2条回答 默认 最新

  • douhui9631 2013-08-07 18:31
    关注

    From Parse js/css as a PHP file using htaccess

    You should just need to add this to your htaccess

    <FilesMatch "\.css$">
      SetHandler application/x-httpd-php
      Header set Content-type "text/css"
    </FilesMatch>
    

    If you're getting a 500 Internal Server Error with the Header line, make sure you have mod_headers enabled in your apache config, if mod_headers is not installed and your provider will not install/enable it, you will need to rename your css file to .php and add into your new php file

    header("Content-type: text/css");
    
    评论

报告相同问题?

悬赏问题

  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 AT89C51控制8位八段数码管显示时钟。
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 下图接收小电路,谁知道原理
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度
  • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测
  • ¥15 ETLCloud 处理json多层级问题