【问题标题】:The images subdomain does not work on my wordpress site when i use https当我使用 https 时,图像子域在我的 wordpress 网站上不起作用
【发布时间】:2016-06-14 18:00:44
【问题描述】:

我使用有效证书开启了 https。我正在尝试将图像放在证书也有效的子域上。这是一个wordpress网站。它托管在 cpanel 中。它适用于http,但不适用于https。 即这工作http://images.mavencomputers.com.au/Logo.png 但这有一个 404 https://images.mavencomputers.com.au/Logo.png

【问题讨论】:

  • 我解决了这个问题。主机只在根域上安装了证书,但这个证书应该在每个子域上单独安装。

标签: wordpress ssl https dns cpanel


【解决方案1】:

我假设您的站点网址在 wp_options 表中以 https:// 开头

你需要更换

<img src="https://example.com/image.jpg" alt="image">

&lt;img src="//example.com/image.jpg" alt="image"&gt; 所以他们将使用当前页面的任何协议加载该资源。

先备份数据库

然后更新 wp_posts

UPDATE wp_posts 
SET    post_content = ( Replace (post_content, 'src="http://', 'src="//') )
WHERE  Instr(post_content, 'jpeg') > 0 
        OR Instr(post_content, 'jpg') > 0 
        OR Instr(post_content, 'gif') > 0 
        OR Instr(post_content, 'png') > 0;

还有一个用来捕捉单引号的,以防万一:

UPDATE wp_posts 
SET   post_content = ( Replace (post_content, "src='http://", "src='//") )
WHERE  Instr(post_content, 'jpeg') > 0 
        OR Instr(post_content, 'jpg') > 0 
        OR Instr(post_content, 'gif') > 0 
        OR Instr(post_content, 'png') > 0;

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2017-05-21
    • 2019-11-06
    • 2020-11-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多