【问题标题】:Hyperlinks to external urls are getting replaced to https in wordpress在 wordpress 中,指向外部 url 的超链接被替换为 https
【发布时间】:2018-10-18 09:51:51
【问题描述】:

嗨,我的 Wordpress 网站最近升级了 SSLCertificate。为了解决混合内容错误,我安装了一个插件(HTTP / HTTPS Remover)来强制 http 到 https。 该站点运行良好,没有混合内容错误,但 站点中作为超链接 (http://walktohealth.org) 的外部 URL 链接将被替换为 https。 如何解决这个问题。

PFB .ht 访问代码;

    # BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^.*[-/]g(\d+)-.*$ index\.php?id=$1&%{QUERY_STRING} [L]
RewriteRule ^g(\d+)-.*$ index\.php?id=$1&%{QUERY_STRING} [L]
RewriteRule ^e(\d+)[-/].*[-/]g(\d+)-.*$ index\.php?id=$1-$2&%{QUERY_STRING} [L]
RewriteRule ^e(\d+)[-/]g(\d+)[-/].*$ index\.php?id=$1-$2&%{QUERY_STRING} [L]
RewriteRule ^g(\d+)[-/].*[-/]e(\d+)[-/].*$ index\.php?id=$2-$1&%{QUERY_STRING} [L]
RewriteRule ^g(\d+)[-/]e(\d+)[-/].*$ index\.php?id=$2-$1&%{QUERY_STRING} [L]
RewriteRule ^.*[-/]g(\d+)[-/]e(\d+)[-/].*$ index\.php?id=$2-$1&%{QUERY_STRING} [L]
RewriteRule ^.*[-/]g(\d+)[-/].*[-/]e(\d+)[-/].*$ index\.php?id=$2-$1&%{QUERY_STRING} [L]
RewriteRule ^.*[-/]e(\d+)[-/].*[-/]g(\d+)[-/].*$ index\.php?id=$1-$2&%{QUERY_STRING} [L]
RewriteRule ^.*[-/]e(\d+)[-/]g(\d+)[-/].*$ index\.php?id=$1-$2&%{QUERY_STRING} [L]

RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
RewriteCond %{HTTP_HOST} mydomainName\.com [NC]
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://www.mydomainName.com/$1 [R,L]
</IfModule>

# END WordPress

1.在菜单中添加外部域名(http://walktohealth.org/)时

2.添加带有外部 URL 的菜单后,当我们单击小部件菜单时,它会变为 https://walktohealth.org/

3.重定向到外部http站点后,如下图

4..whynopadlock.com/results

【问题讨论】:

  • 替换数据库中所有混合内容并卸载这样的不良插件
  • 请使用更好的搜索替换插件将所有http替换为https。 wordpress.org/plugins/better-search-replace 插件还提供了试运行,所以你可以很容易地理解和查看内容中有多少http URL。还提供良好的数据库表选择功能。
  • @Tobias 我的网站没有混合内容问题。问题是外部链接也重定向为 https,即使不是。
  • @Dolar PFA 截图来解释我面临的问题。

标签: php wordpress .htaccess ssl-certificate web-hosting


【解决方案1】:

要强制将 url 从 http 更改为 https,请从 wordpress 根目录备份您的 .htaccess 文件。并在根目录创建新的 .htaccess 文件并将以下代码粘贴到 .htaccess 文件中。

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /

RewriteCond %{ENV:HTTPS} !=on
RewriteRule ^.*$ https://%{SERVER_NAME}%{REQUEST_URI} [R,L]

# BEGIN WordPress
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule> 

希望对你有帮助。

【讨论】:

【解决方案2】:

感谢支持

我的问题得到了答案

Click here for detailed post on wordpress.stackexchange.com

在菜单设置中的自定义 URL 上,可以使用相对链接 到[博客网址]。秘诀是以相对 URL 开头 单身的 /。当单个 / 启动自定义 URL 时,系统不会 在前面加上典型的 http:// 然后当前 blogURL 将是 在执行时在目标 URL 中生成。

示例 如果你想去你的主页,只需将 / 作为自定义 URL

如果您想进入文件夹 bbforums 中的索引页面,请将 /bbforums 作为自定义 URL。

这允许您将站点移动到测试域,而无需在菜单的所有自定义链接中硬编码新的 blogURL。

例如: 如果我的博客是http://example.com 并且我想在子域http://test.example.com 中对其进行测试,则可以使用上面提到的相对 URL 约定在测试和生产之间移动站点而不会出现菜单问题。我已经使用 XCloner 插件成功测试了这种方法来移动站点。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2010-12-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-07-05
    • 1970-01-01
    • 2016-05-03
    • 2015-06-25
    相关资源
    最近更新 更多