【发布时间】:2019-11-21 06:24:17
【问题描述】:
我已经在 http2 上配置了我的网站,但即使阅读了这么多文章,我也无法弄清楚它的一些实现。
我已经从我网站的头文件中删除了common.css。并将这些行添加到.htaccess 文件中。
<IfModule http2_module>
#Check if there's a cookie saying the css has already been loaded:
SetEnvIf Cookie "cssloaded=1" cssloaded
#If no cookie, and it's an html file, then push the css file
#and set a session level cookie so next time it won't be pushed:
<filesMatch "\.([pP][hH][pP]?)">
Header add Link "</assets/css/common.css>;rel=preload;as=style" env=!cssloaded
Header add Set-Cookie "cssloaded=1; Path=/; Secure; HttpOnly" env=!cssloaded
</filesMatch>
</IfModule>
但是我的网站根本没有加载common.css。它坏了。我的网站位于 Apache 服务器之后,并且网站完全建立在 codeIgniter 之上。
我也确实将这些添加到了我的 common_head.php 文件中
<?php
header: header('Link: </assets/css/jquery-ui.css>; rel=preload; as=style,</assets/css/jquery.mCustomScrollbar.min.css>; rel=preload; as=style,</assets/css/slick.min.css>; rel=preload; as=style,</assets/css/slick-theme.min.css>; rel=preload; as=style,</assets/css/bootstrap.min.css>; rel=preload; as=style,</assets/css/common.css>; rel=preload; as=style,,</assets/css/jplayer.blue.monday.min.css>; rel=preload; as=style');
?>
现在我可以在检查元素中看到所有的 css 文件,也可以看到初始化程序推送/其他,但它不适用于页面。页面已损坏。 阿帕奇服务器:2.4.6
请告诉我哪里做错了?
【问题讨论】:
标签: php apache .htaccess http2