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

WordPress多站点首页Logo跳转异常:需跳转至父站点或自定义URL

WordPress Multisite: Subsite Logo Not Redirecting to Parent Site/Custom URL

Hey there, let's work through this multisite logo redirect issue together—this is a common snag with WP multisite setups, so I’ve got a few solid steps to fix it.

1. First: Double-Check Your Template Header Edits (This is Almost Always the Fix)

First off, let’s make sure you’re modifying the right file and using the correct code:

  • Confirm you’re editing the active theme’s header.php for the subsite in question. Multisite lets each subsite use its own theme, so it’s easy to accidentally tweak a parent theme or inactive theme file by mistake.
  • Find the logo’s anchor tag in your header.php—it usually looks something like this:
    <a href="<?php echo get_home_url(); ?>" class="site-logo">
      <!-- Logo image here -->
    </a>
    
    The get_home_url() function defaults to the current subsite’s homepage, which is why your redirect isn’t working. Replace it with one of these options:
    • To redirect to the main parent site: Use get_site_url(1) (the 1 refers to the parent site’s ID, which is almost always 1—you can confirm this in your Network Admin > Sites list).
    • To redirect to a custom URL: Just hardcode the URL, like <a href="https://your-custom-url.com">.
  • Example of the fixed code:
    <a href="<?php echo get_site_url(1); ?>" class="site-logo">
      <img src="<?php echo get_stylesheet_directory_uri(); ?>/images/logo.png" alt="Main Site Logo">
    </a>
    
  • Don’t forget to clear cache! WordPress cache plugins, server-side cache, or even your browser’s cache can prevent changes from showing up immediately. Flush all of them after making edits.

2. Do You Need to Edit .htaccess? Probably Not (Unless There’s a Rewrite Conflict)

9 times out of 10, logo redirects are controlled by your theme template, not .htaccess. But if you’ve ruled out template issues, here’s what to check:

  • First, back up your current .htaccess file (always a good habit!).
  • Compare your file to WordPress’s default multisite rules to spot rogue rewrite rules:
    • For subdirectory multisite setups:
      RewriteEngine On
      RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
      RewriteBase /
      RewriteRule ^index\.php$ - [L]
      
      # Add trailing slash to /wp-admin
      RewriteRule ^wp-admin$ wp-admin/ [R=301,L]
      
      RewriteCond %{REQUEST_FILENAME} -f [OR]
      RewriteCond %{REQUEST_FILENAME} -d
      RewriteRule ^ - [L]
      RewriteRule ^(wp-(content|admin|includes).*) $1 [L]
      RewriteRule ^(.*\.php)$ $1 [L]
      RewriteRule . index.php [L]
      
    • For subdomain multisite setups:
      RewriteEngine On
      RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
      RewriteBase /
      RewriteRule ^index\.php$ - [L]
      
      # Add trailing slash to /wp-admin
      RewriteRule ^wp-admin$ wp-admin/ [R=301,L]
      
      RewriteCond %{REQUEST_FILENAME} -f [OR]
      RewriteCond %{REQUEST_FILENAME} -d
      RewriteRule ^ - [L]
      RewriteRule ^(wp-(content|admin|includes).*) $1 [L]
      RewriteRule ^(.*\.php)$ $1 [L]
      RewriteRule . index.php [L]
      
  • If you have custom rewrite rules added, temporarily remove them to see if they’re interfering with the logo redirect.

3. Bonus Debugging Steps

  • Check your theme’s customizer: Some themes have a built-in setting under Appearance > Customize for the logo’s redirect URL. If this is set, it might override your header.php edits.
  • Inspect the logo with browser dev tools: Right-click the logo, select "Inspect," and look at the rendered href attribute. If it’s still pointing to the subsite, either your template edit didn’t save, you edited the wrong file, or cache is holding onto old content.
  • If using a child theme: Make sure you’re editing the child theme’s header.php instead of the parent theme—parent theme updates will overwrite your changes otherwise.

内容的提问来源于stack exchange,提问作者Gideon Koney

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.28 04:02:31