header(“Content-type: text/css”); is working in Firefox and Chrome, but in Internet Explorer 9 it shows up as 'text/html'

前端 未结 8 1025
时光取名叫无心
时光取名叫无心 2020-12-01 09:12

header(\"Content-type: text/css\"); works in Firefox, Chrome and other, but not in Internet Explorer 9. I am not sure what\'s up.

In Chrome an

相关标签:
8条回答
  • 2020-12-01 09:54

    Is there any output before the header is sent? BOM in the php file? A carriage return?

    If you disabled error reporting, you may not see the error it should trigger.

    Try adding ob_start() on top, it will resolve any issue related to headers already sent before any header() call.

    If you have a BOM in your UTF8 file, you may want to remove it.

    0 讨论(0)
  • 2020-12-01 10:00

    For Internet Explorer 9 serving HTTP 406 status code in the response header for a dynamically generated CSS file we:

    1. Removed the Apache mod_negiotiation module or added -Multiviews to the host configuration (or .htaccess).
    2. Activated Apache mod_rewrite
    3. Added a rewrite rule to the virtual host configuration or htaccess:

      <IfModule mod_rewrite.c
      
        RewriteEngine on
        RewriteBase /
      
        #serve CSS and JS from combine.php
        RewriteRule ^combine(.*) combine.php [NC,L]
      
      </IfModule>
      

    Note: This solution is only good for servers/virtual-hosts not using Multiviews as removing mod_negotiation removes usage of this directive as well.

    0 讨论(0)
提交回复
热议问题