I recently setup a WordPress multisite install using subdomains and the WordPress MU domain mapping plugin.

When I initially setup the domain mapping plugin, I set the root (http://domain.com) and http://www.domain.com to redirect to blog ID 2 (ie. www.domain.com). However, when I do this the redirect on the root prevents me from accessing the Network admin page.

Is there a way I can change the configuration to enable me to still access the Network admin page whilst redirecting the root site to www?

  • Can you remove the redirection from the domain mapping plugin, and place redirection of non-www to www in .htaccess using normal rewrite rules?
    – Steve
    May 20, 2012 at 8:55
  • Shouldn't this part read like: "blog ID 2 (ie. www.another-domain.com)"?
    – brasofilo
    May 22, 2012 at 10:46

2 Answers 2


I was in a similar situation recently. I ended up putting the root site on a random subdomain (eg ms.domain.com) With the intention of never using the root site.

With that done, I created a plugin to activate only on the main (root) site.

The plugin hooks into a action that fires only on the front end (template_redirect). From there, call wp_redirect to send your visitors to where they need to be.

add_action('template_redirect', 'wpse52298_redirect');
 * Redirects all requests to the front end to another site
 * @uses wp_redirect
function wpse52298_redirect()
    // change this
    $to = 'http://www.example.com';



  • Loads basically all of WP before redirecting
  • Not as fast as redirecting in htaccess


  • Easy to maintain
  • No htaccess foo required

As a plugin.

  • Thanks Chris! I believe this is a better approach than creating a custom theme or editing .htaccess.
    – Shahriar
    Aug 17, 2021 at 19:39

I recommend using this solution:

RewriteEngine on
RewriteCond %{HTTP_HOST} ^mysite\.com$
RewriteCond %{REQUEST_URI} ^/$
Rewriterule ^(.*)$ http://mysecondsite.com/ [L,R=301]

as it preserves the root domain's subdirectories, allowing you to manage the multisite admin dashboard.

Source: How to redirect root and only root via htaccess?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.