Alternatives to PHP header function

前端 未结 2 1368
礼貌的吻别
礼貌的吻别 2021-01-13 17:51

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 som

2条回答
  •  没有蜡笔的小新
    2021-01-13 18:14

    You should be able to just add a .php extension to all of your CSS files; this will cause the server to pass all of the "normal" CSS as just that, whereas all of your dynamic, PHP-generated CSS should be parsed. After that, it's just a matter of slightly modifying the way in which you link your stylesheets:

    
    

    Though that's always done the trick for me, there's a slight chance you may need to explicitly declare the MIME type of your CSS files using PHP's header() function, like so:

    header('Content-type: text/css');
    

提交回复
热议问题