dongpanbo4727 2016-09-08 14:55
浏览 242

Laravel是否更改了我的.css文件的内容类型?

Today I tried to publish a site developed in Laravel. When I have send all my files on the server I realised that styles are not being applied. Css file are being loaded, because I get in console:

Resource interpreted as Stylesheet but transferred with MIME type text/html: "http://xxx.xx/build/css/app-e3022e1832.css"

And I think here is the problem. Take a look at headers of app-e3022e1832.css, escpecialy at Content-Type:

HTTP/1.1 200 OK
Date: Thu, 08 Sep 2016 14:27:29 GMT
Content-Type: text/html; charset=UTF-8
Transfer-Encoding: chunked
Connection: keep-alive
Server: IdeaWebServer/v0.80
Content-Encoding: gzip

When I put the same .css file on an external server, than the file gets Content-Type: text/css and everything is working fine. The same thing happens when I deleted all Laravel files, than my css files are getting normal Content-Type: text/css and styles are being applied properly.

That gives us a proposal, that Laravel is changing the Content-Type of .css files, but I used Laravel in another projects and everything was working fine. What could be the problem?

  • 写回答

1条回答 默认 最新

  • doujionggan9570 2016-09-08 14:55
    关注

    The problem was not with Laravel, but with the .htaccess file. When I uploaded files to the server I realised that I need php7. My hosting provider allows to choose php version in htaccess files. I wrote on the top of my .htaccess:

    use php7
    

    But that was wrong. I should write:

    :Location /*.php
    Use php7
    :Location
    

    This is maybe very custom solution and very special problem, but if somebody have a similar problem to mine, you can make sure that everything is okay with your php version and .htaccess file.

    评论

报告相同问题?

悬赏问题

  • ¥15 Vue3 大型图片数据拖动排序
  • ¥15 划分vlan后不通了
  • ¥15 GDI处理通道视频时总是带有白色锯齿
  • ¥20 用雷电模拟器安装百达屋apk一直闪退
  • ¥15 算能科技20240506咨询(拒绝大模型回答)
  • ¥15 自适应 AR 模型 参数估计Matlab程序
  • ¥100 角动量包络面如何用MATLAB绘制
  • ¥15 merge函数占用内存过大
  • ¥15 使用EMD去噪处理RML2016数据集时候的原理
  • ¥15 神经网络预测均方误差很小 但是图像上看着差别太大