Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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?

share|improve this question
    
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 '12 at 8:55
    
Shouldn't this part read like: "blog ID 2 (ie. www.another-domain.com)"? –  brasofilo May 22 '12 at 10:46

1 Answer 1

up vote 0 down vote accepted
+50

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.

<?php
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';

    wp_redirect(esc_url($to));
    exit();
}

Cons:

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

Pros:

  • Easy to maintain
  • No htaccess foo required

As a plugin.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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