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");
    
    评论

报告相同问题?

悬赏问题

  • ¥15 FPGA-SRIO初始化失败
  • ¥15 MapReduce实现倒排索引失败
  • ¥15 ZABBIX6.0L连接数据库报错,如何解决?(操作系统-centos)
  • ¥15 找一位技术过硬的游戏pj程序员
  • ¥15 matlab生成电测深三层曲线模型代码
  • ¥50 随机森林与房贷信用风险模型
  • ¥50 buildozer打包kivy app失败
  • ¥30 在vs2022里运行python代码
  • ¥15 不同尺寸货物如何寻找合适的包装箱型谱
  • ¥15 求解 yolo算法问题