V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
yuhaaitao
V2EX  ›  SSL

如何删除主页不支持 https 的 css?

  •  
  •   yuhaaitao · 2016-09-18 12:56:52 +08:00 · 4585 次点击
    这是一个创建于 2988 天前的主题,其中的信息可能已经有所发展或是发生改变。
    chrome 打开博客主页,提示有部分链接不支持 https ,怎么替换掉呢?
    Mixed Content: The page at 'https://yuhaitao.com/' was loaded over HTTPS, but requested an insecure stylesheet 'http://cdn.staticfile.org/normalize/2.1.3/normalize.min.css'. This request has been blocked; the content must be served over HTTPS.
    https://yuhaitao.com/favicon.ico Failed to load resource: the server responded with a status of 404 (Not Found)

    这是在 chrome 诊断页面复制的不支持 https 的链接
    <!DOCTYPE HTML>
    <html class="no-js">
    <head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge, chrome=1">
    <meta name="renderer" content="webkit">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title>临海听涛</title>

    <!-- 使用 url 函数转换相关路径 -->
    <link rel="stylesheet" href="http://cdn.staticfile.org/normalize/2.1.3/normalize.min.css">


    下面是默认主题 index.php ,没有找到 link rel="stylesheet" href="http://cdn.staticfile.org/normalize/2.1.3/normalize.min.css"

    <?php
    /**
    * 这是 Typecho 0.9 系统的一套默认皮肤
    *
    * @package Typecho Replica Theme
    * @author Typecho Team
    * @version 1.2
    * @link http://typecho.org
    */

    if (!defined('__TYPECHO_ROOT_DIR__')) exit;
    $this->need('header.php');
    ?>

    <div class="col-mb-12 col-8" id="main" role="main">
    <?php while($this->next()): ?>
    <article class="post" itemscope itemtype="http://schema.org/BlogPosting">
    <h2 class="post-title" itemprop="name headline"><a itemtype="url" href="<?php $this->permalink() ?>"><?php $this->title() ?></a></h2>
    <ul class="post-meta">
    <li itemprop="author" itemscope itemtype="http://schema.org/Person"><?php _e('作者: '); ?><a itemprop="name" href="<?php $this->author->permalink(); ?>" rel="author"><?php $this->author(); ?></a></li>
    <li><?php _e('时间: '); ?><time datetime="<?php $this->date('c'); ?>" itemprop="datePublished"><?php $this->date('F j, Y'); ?></time></li>
    <li><?php _e('分类: '); ?><?php $this->category(','); ?></li>
    <li itemprop="interactionCount"><a itemprop="discussionUrl" href="<?php $this->permalink() ?>#comments"><?php $this->commentsNum('评论', '1 条评论', '%d 条评论'); ?></a></li>
    </ul>
    <div class="post-content" itemprop="articleBody">
    <?php $this->content('- 阅读剩余部分 -'); ?>
    </div>
    </article>
    <?php endwhile; ?>

    <?php $this->pageNav('&laquo; 前一页', '后一页 &raquo;'); ?>
    </div><!-- end #main-->

    <?php $this->need('sidebar.php'); ?>
    <?php $this->need('footer.php'); ?>
    12 条回复    2016-09-19 12:20:37 +08:00
    yuhaaitao
        1
    yuhaaitao  
    OP
       2016-09-18 12:58:42 +08:00
    Mixed Content: The page at 'https://yuhaitao.com/the-music-migu-sign-to-send-traffic/' was loaded over HTTPS, but requested an insecure stylesheet 'http://cdn.staticfile.org/normalize/2.1.3/normalize.min.css'. This request has been blocked; the content must be served over HTTPS.
    (index):227 Mixed Content: The page at 'https://yuhaitao.com/the-music-migu-sign-to-send-traffic/' was loaded over HTTPS, but requested an insecure image 'http://image.yuhaitao.com/4f632767ac0d_CDB5/Screenshot_20151208140849_cmccwm.mobilemusic.png'. This content should also be served over HTTPS.
    (index):227 Mixed Content: The page at 'https://yuhaitao.com/the-music-migu-sign-to-send-traffic/' was loaded over HTTPS, but requested an insecure image 'http://image.yuhaitao.com/4f632767ac0d_CDB5/Screenshot_20151208140918_cmccwm.mobilemusic.png'. This content should also be served over HTTPS.
    (index):227 Mixed Content: The page at 'https://yuhaitao.com/the-music-migu-sign-to-send-traffic/' was loaded over HTTPS, but requested an insecure image 'http://image.yuhaitao.com/4f632767ac0d_CDB5/Screenshot_20151208143831_com.sunbelt.androidbutler.png'. This content should also be served over HTTPS.

    之前文章的图片链接怎么换成 https?
    lhbc
        2
    lhbc  
       2016-09-18 13:16:36 +08:00   ❤️ 1
    1 、替换所有文件里的连接
    2 、如果你确定 image.yuhaitao.com 支持 https ,但又懒得替换或者怕替换不完整,可以在头部加这个字段,现代浏览器会自动升级协议
    Content-Security-Policy: upgrade-insecure-requests
    yuhaaitao
        3
    yuhaaitao  
    OP
       2016-09-18 13:30:23 +08:00
    @lhbc 那个 cdn 链接我在网站里找不到在哪里?
    头部加这个字段是主题中的 index.php 吗?
    lhbc
        4
    lhbc  
       2016-09-18 13:42:03 +08:00   ❤️ 1
    @yuhaaitao
    1. 这个得你自己找了
    2. 所有页面,最简单的方法是在 nginx 里加上这个头部
    loading
        5
    loading  
       2016-09-18 13:56:10 +08:00 via Android   ❤️ 1
    加到 <style>,逃~
    yuhaaitao
        6
    yuhaaitao  
    OP
       2016-09-18 16:14:02 +08:00
    @lhbc 虚拟主机,能在 nginx 里加吗?
    lhbc
        7
    lhbc  
       2016-09-18 16:24:16 +08:00   ❤️ 1
    @yuhaaitao 虚拟主机不能改 nginx 配置
    可以在 meta 里加
    <meta http-equiv="Content-Security-Policy" content="upgrade-insecure-requests">
    JimmyCai
        8
    JimmyCai  
       2016-09-18 17:25:15 +08:00 via Android   ❤️ 1
    在 header.php 找
    kawaiiushio
        9
    kawaiiushio  
       2016-09-18 20:13:12 +08:00 via iPhone   ❤️ 1
    VmuTargh
        10
    VmuTargh  
       2016-09-18 23:55:36 +08:00 via Android   ❤️ 1
    At header.php
    Solutions: replace/remove, CSP
    yuhaaitao
        11
    yuhaaitao  
    OP
       2016-09-19 10:53:57 +08:00
    @VmuTargh Solutions: replace/remove, CSP 添到那里?
    index.php 是这样的。

    <?php
    /**
    * Typecho Blog Platform
    *
    * @copyright Copyright (c) 2008 Typecho team ( http://www.typecho.org)
    * @license GNU General Public License 2.0
    * @version $Id: index.php 1153 2009-07-02 10:53:22Z magike.net $
    */

    /** 载入配置支持 */
    if (!defined('__TYPECHO_ROOT_DIR__') && !@include_once 'config.inc.php') {
    file_exists('./install.php') ? header('Location: install.php') : print('Missing Config File');
    exit;
    }

    /** 初始化组件 */
    Typecho_Widget::widget('Widget_Init');

    /** 注册一个初始化插件 */
    Typecho_Plugin::factory('index.php')->begin();

    /** 开始路由分发 */
    Typecho_Router::dispatch();

    /** 注册一个结束插件 */
    Typecho_Plugin::factory('index.php')->end();
    yuhaaitao
        12
    yuhaaitao  
    OP
       2016-09-19 12:20:37 +08:00
    已解决,在默认主题 header.php 中按照 @lhbc 提到的在 meta 里加
    <meta http-equiv="Content-Security-Policy" content="upgrade-insecure-requests">
    替换'http://cdn.staticfile.org/normalize/2.1.3/normalize.min.css'为本地路径就好了。
    chrome 终于全绿了
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   1082 人在线   最高记录 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 23ms · UTC 19:07 · PVG 03:07 · LAX 11:07 · JFK 14:07
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.