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.

If we try to access a non-existant Multisite site, e.g., http://site1.example.com or http://example.com/site1/, we are redirected to http://example.com/wp-signup.php?new=site1.

How to block this and redirect the browser to another page?

share|improve this question
add comment

1 Answer

up vote 5 down vote accepted

[Update]

An alternative (maybe better) is to use the following constant in wp-config.php:

define( 'NOBLOGREDIRECT', 'http://example.com' );

At the very beginning of wp-signup.php file there is this code:

function do_signup_header() {
    do_action( 'signup_header' );
}
add_action( 'wp_head', 'do_signup_header' );

So, it's just a matter of adding the signup_header action hook to break any further execution and redirect the browser to other URL.

Here, wrapped as a Must Use Plugin:

<?php
/*
    Plugin Name: Multisite - Prevent Sign-up Page
    Plugin Url: http://wordpress.stackexchange.com/q/85529/12615
    Version: 1.0
    Author: Rodolfo Buaiz
*/

add_action( 'signup_header', 'rbz_prevent_multisite_signup' );

function rbz_prevent_multisite_signup() 
{
    wp_redirect( site_url() );
    die();
}
share|improve this answer
    
+1 and added to mu-plugins :) –  kaiser Feb 12 '13 at 11:25
1  
@kaiser, always disliked this behavior in closed networks ;) –  brasofilo Feb 13 '13 at 12:18
    
hey, unser @kaiser, there's a better alternative, IMO. Updated the A with it. Also published a related one. –  brasofilo May 3 '13 at 1:18
    
I just wanted to state that I dislike the core behavior. In the meanwhile I found the regarding DropIns, when I talked about them. +1 on both answers. –  kaiser May 3 '13 at 10:12
add comment

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.