You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

单页面跨3域名链式跳转需求及WordPress适配插件咨询

单页面链式域名跳转实现方案及WordPress适配插件

一、手动实现单页面链式跳转

要实现domain.com/xxx → domain.tk/xxx → domain.eu/xxx的链式跳转,核心是确保每个域名下的对应路径页面存在,并添加跳转逻辑:

  1. domain.com目标页面(如domain.com/post-123):
    在页面<head>中添加元刷新或JS跳转代码:

    <!-- 元刷新跳转(3秒延迟,可修改数字) -->
    <meta http-equiv="refresh" content="3; url=https://domain.tk/post-123">
    
    <!-- JS跳转,支持自定义逻辑 -->
    <script>
      setTimeout(() => {
        window.location.href = 'https://domain.tk/post-123';
      }, 3000); // 3000毫秒=3秒
    </script>
    
  2. domain.tk目标页面(domain.tk/post-123):
    同样添加跳转代码指向最终域名的对应页面:

    <meta http-equiv="refresh" content="3; url=https://domain.eu/post-123">
    
  3. domain.eu目标页面:
    作为最终落地页,正常展示内容即可,无需跳转代码。

注意:三个域名下的页面路径必须完全对应,否则会出现404错误。

二、WordPress适配插件及配置

如果使用WordPress搭建站点,以下方案可实现单页面级别的链式跳转:

1. Redirection(推荐)

功能强大的跳转管理插件,支持单页面/自定义路径的链式跳转配置:

  • 安装激活后,进入工具 > Redirection
  • 在domain.com站点添加第一条规则:
    • 源URL:/post-123(对应要跳转的页面路径)
    • 目标URL:https://domain.tk/post-123
    • 匹配类型选"精确",动作选"重定向(302临时)"或"重定向(301永久)"
  • 切换到domain.tk站点,添加第二条规则:
    • 源URL:/post-123
    • 目标URL:https://domain.eu/post-123
  • 重复步骤为每个需要跳转的页面配置对应规则。

2. Quick Page/Post Redirect Plugin

专门针对页面/文章的跳转插件,操作直观:

  • 激活插件后,编辑domain.com上的目标页面(如post-123)
  • 在页面编辑页的"Quick Redirect"模块中,设置"Redirect URL"为https://domain.tk/post-123,选择跳转类型
  • 同理在domain.tk的对应页面中,设置跳转目标为https://domain.eu/post-123

3. 自定义函数实现(无需插件)

在每个站点的functions.php中添加代码,实现单页面跳转:

// domain.com站点的functions.php
add_action('template_redirect', 'chain_redirect_step1');
function chain_redirect_step1() {
  $target_post_id = 123; // 替换为目标页面ID
  if (is_single($target_post_id) || is_page($target_post_id)) {
    wp_redirect('https://domain.tk/post-123', 302);
    exit;
  }
}

// domain.tk站点的functions.php
add_action('template_redirect', 'chain_redirect_step2');
function chain_redirect_step2() {
  $target_post_id = 123;
  if (is_single($target_post_id) || is_page($target_post_id)) {
    wp_redirect('https://domain.eu/post-123', 302);
    exit;
  }
}

说明:302为临时跳转,永久跳转可改为301;需根据实际页面修改$target_post_id和跳转URL。

关键注意事项

  • 所有域名需完成DNS解析并绑定到对应站点,确保页面路径可访问
  • 批量处理大量页面时,可使用插件批量导入功能或自定义循环代码
  • 跳转延迟可按需调整,建议保留短暂延迟提升用户体验

内容的提问来源于stack exchange,提问作者Re O

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.04 03:50:17