nginx和openresty配置静态资源时,样式错乱

问题

nginx和openresty配置静态资源时,样式错乱,页面没有报错,查看css,作为静态文件已经加载了,但是不起作用。

原因

CSS加载过程,发现CSS加载时Content Type为“text/plain",不是”text/css“,所以才想起是MIME type的问题。

解决

nginx.conf中添加include mime.types;问题解决。

Openresty中不会加载默认的mime.types,需要自己手动添加,

Openresty中的mime.types文件所在位置openresty-1.15.8.2/build/nginx-1.15.8/conf/mime.types

猜你喜欢

转载自blog.csdn.net/weixin_42170236/article/details/103701126