Browser Not Interpreting .css File when using AddType .css in .htaccess

I have a very interesting problem related to Deflate Compression, Apache (htaccess), and CSS files. I have two CSS files on my server. One is called styles.php and has dynamic values added based on database values through mod_rewrite in the styles/ directory (it is rewritten from styles.php to site.css and there is a text/css header at the beginning of the file). I also have a regular old css file with static content that doesn't change in the same directory called styles.css. I've wanted to add compression to my site so I added the following line to start compressing my css and js files. I added this to the root_directory for my website. SetOutputFilter DEFLATE Well initially that didn't work. So I changed this line in the root htaccess file from this to the next thing. (this code below is located at the top of the file) AddType application/x-httpd-php5 .html .php AddType application/x-httpd-php5 .html .php .js .css Then my js and one of the css files started to be compressed (verified with YSlow.....yay!). The odd thing was the css file that was being rewritten was being compressed (the styles.php file) but the styles.css file (the static one) was no longer being read by the browser. As soon as I deleted ".css" from that AddType line the browser started reading the file again and my css returned to normal, however it was no longer being compressed through apache. Any thoughts on why a static css file is not being read by the browser if I add the type? I tried it with just text/css instead of .css and it was not compressing the file (but the browser interpreted it). UPDATE: I added this to the root htaccess file. We have compressed, interpretted sweetness now. FileETag None Header set Content-type "text/css"
Do you receive proper Content-Encoding and Content-Type headers for this static css file?

以上就是Browser Not Interpreting .css File when using AddType .css in .htaccess的详细内容,更多请关注web前端其它相关文章!

赞(0) 打赏
未经允许不得转载:web前端首页 » CSS3 答疑

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

前端开发相关广告投放 更专业 更精准

联系我们

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

微信扫一扫打赏