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

WordPress博客重定向方案咨询:特定文章跳转及全局兜底设置

Hey there! Let’s tackle your WordPress redirection puzzle step by step. The choice between .htaccess and plugins boils down to your technical comfort and what you need long-term, so I’ll break down both options clearly:

Which to Choose?
  • .htaccess is better if you’re comfortable editing server files: it’s faster (server-level redirection, skips WordPress’s runtime processing) and more lightweight. Great for permanent, high-performance redirects.
  • Plugins are ideal for beginners or anyone who prefers visual management: no code required, you can easily edit/remove redirects later, and most plugins include logging to track what’s being redirected.

Option 1: Using .htaccess (For Technical Users)

First, always back up your .htaccess file before editing—it lives in your site’s root directory. Rules are processed top-to-bottom, so we’ll add specific redirects first, then the global fallback.

  1. Add Specific Post Redirects
    Place these rules before WordPress’s default # BEGIN WordPress block (to ensure they’re matched first). For example, if you want /my-old-post/ to redirect to an external page:

    # Redirect specific post to external page
    Redirect 301 /my-old-post/ https://external-site.com/replacement-page/
    

    Add a separate line for each specific post you need to redirect.

  2. Add Global Fallback Redirect
    This rule will catch all other requests—except WordPress core files/directories (so you can still access the admin area) and your target landing page (to avoid infinite loops). Add this below your specific redirects, still outside the WordPress block:

    # Redirect all other requests to your specific page
    RewriteEngine On
    RewriteCond %{REQUEST_URI} !^/wp-admin/
    RewriteCond %{REQUEST_URI} !^/wp-content/
    RewriteCond %{REQUEST_URI} !^/wp-includes/
    RewriteCond %{REQUEST_URI} !^/wp-login.php
    RewriteCond %{REQUEST_URI} !^/your-target-landing-page/$  # Replace with your actual page URL
    RewriteRule ^(.*)$ /your-target-landing-page/ [R=301,L]
    

    Replace /your-target-landing-page/ with the actual relative URL of your fallback page.


Option 2: Using a WordPress Plugin (For Beginners)

The Redirection plugin is the gold standard for this—it’s free, widely used, and handles both specific and global redirects with ease.

  1. Set Up Specific Post Redirects

    • Install and activate the Redirection plugin, then go to Tools > Redirection.
    • Click the Add New button.
    • In the Source URL field, enter the relative path of your old post (e.g., /my-old-post/).
    • In the Target URL field, paste the external page’s full URL.
    • Set Redirect Type to 301 (Permanent) (best for SEO).
    • Click Add Redirect—repeat for every specific post you need to redirect.
  2. Set Up Global Fallback Redirect
    To redirect all non-specified requests (including existing pages) to your target page, use a regex redirect:

    • Click Add New again, then toggle the Regex switch to On.
    • In Source URL, paste this pattern (replace the paths with your specific post, target page, and core directories):
      ^(?!/my-old-post/|/wp-admin/|/wp-content/|/wp-includes/|/wp-login.php|/your-target-landing-page/).*$
      
      This regex says: "Match any URL that is NOT my specific post, core WordPress paths, or my target landing page."
    • In Target URL, enter your fallback page’s relative URL (e.g., /your-target-landing-page/).
    • Set Redirect Type to 301 (Permanent) and save.

Quick Notes

  • Always test redirects after setting them up—use incognito mode to avoid cache issues.
  • 301 redirects are permanent and pass SEO value; use 302 only if you plan to revert the redirect later.

内容的提问来源于stack exchange,提问作者Shonna Edwards Martell

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.21 04:29:02