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

WordPress站点旧域名内链301重定向至新域名问题求助

Fixing Full-Site Redirects for Your WordPress Site

Hey there, let's get those inner page redirects sorted out—you're halfway there with the root domain working!

Why Your Current Rule Only Handles the Root

Your existing RewriteRule ^/?$ "https\:\/\/wsx\.com\/home-page\/" [R=301,L] works perfectly for the root domain (qaz.com), but it only matches URLs with no path after the domain. Any inner page like qaz.com/home-page/professional-theme/ doesn't trigger this rule, which is why those links aren't redirecting.

Solution 1: Adjust Your .htaccess Rules

We'll add two targeted rules to cover both the root domain and all inner pages. Here's the full code to drop into your .htaccess file:

RewriteEngine On

# Redirect root domain (qaz.com) to wsx.com/home-page/
RewriteRule ^/?$ https://wsx.com/home-page/ [R=301,L]

# Redirect all other pages from qaz.com to wsx.com, keeping their full path
RewriteCond %{HTTP_HOST} ^qaz\.com$ [NC]
RewriteRule ^(.*)$ https://wsx.com/$1 [R=301,L]

What Each Rule Does:

  • First rule: Targets only the root path (either an empty string or just /) and sends it straight to wsx.com/home-page/—this preserves your existing root redirect behavior.
  • Second rule: Checks if the request comes from qaz.com (the NC flag makes this case-insensitive), captures everything after the domain (like /home-page/professional-theme/), and appends that path to wsx.com.

Critical Notes:

  • Order matters: Place these rules before WordPress's default rewrite block (which starts with # BEGIN WordPress). If you put them after, WordPress's internal routing might take over first.
  • Clear your cache: 301 redirects are cached heavily by browsers, so you might not see changes right away. Test in incognito mode or clear your browser cache to verify.
  • HTTPS check: Ensure target URLs use https:// to avoid mixed-content errors if your new site uses SSL.

Solution 2: Use a WordPress Plugin (No Code Needed)

If you'd rather not edit .htaccess directly, the Redirection plugin makes managing these redirects straightforward:

  1. Install and activate the Redirection plugin from your WordPress dashboard's Plugin Directory.
  2. Head to Tools > Redirection to access the plugin settings.
  3. Add two separate redirects:
    • For the root domain:
      • Source URL: ^$ (matches only the root path)
      • Target URL: https://wsx.com/home-page/
      • Redirect Type: 301 - Permanent
    • For all inner pages:
      • Source URL: ^(.*)$ (uses regex to capture every path)
      • Target URL: https://wsx.com/$1 (the $1 pulls in the captured path from the source)
      • Under "Match", select "Regex"
      • Redirect Type: 301 - Permanent
  4. Save both redirects, and you're done!

Final Check

After setting up either solution, test a few URLs to confirm everything works:

  • qaz.com → should redirect to wsx.com/home-page/
  • qaz.com/home-page/professional-theme/ → should redirect to wsx.com/home-page/professional-theme/
  • Any other inner page on qaz.com should land on its exact counterpart on wsx.com

内容的提问来源于stack exchange,提问作者serversetup co

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.13 08:40:48