summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--wp-config-sample.php4
-rw-r--r--wp-includes/wpmu-functions.php16
-rw-r--r--wpmu-settings.php7
3 files changed, 19 insertions, 8 deletions
diff --git a/wp-config-sample.php b/wp-config-sample.php
index fc75fec..b622897 100644
--- a/wp-config-sample.php
+++ b/wp-config-sample.php
@@ -35,8 +35,8 @@ define ('WPLANG', '');
// uncomment this to enable wp-content/sunrise.php support
//define( 'SUNRISE', 'on' );
-// Uncomment and set this to a URL to redirect if a blog does not exist. (Useful if signup is disabled)
-// Browser will redirect to constant( 'NOBLOGREDICT' ) . "?new=blogname" where blogname is the unknown blog
+// Uncomment and set this to a URL to redirect if a blog does not exist or is a 404 on the main blog. (Useful if signup is disabled)
+// For example, browser will redirect to http://examples.com/ for the following: define( 'NOBLOGREDIRECT', 'http://example.com/' );
// define( 'NOBLOGREDIRECT', '' );
define( "WP_USE_MULTIPLE_DB", false );
diff --git a/wp-includes/wpmu-functions.php b/wp-includes/wpmu-functions.php
index e6f16f6..c67001b 100644
--- a/wp-includes/wpmu-functions.php
+++ b/wp-includes/wpmu-functions.php
@@ -100,6 +100,13 @@ function get_user_details( $username ) {
return $wpdb->get_row( "SELECT * FROM $wpdb->users WHERE user_login = '$username'" );
}
+function is_main_blog() {
+ global $current_blog, $current_site;
+ if( $current_blog->domain == $current_site->domain && $current_blog->path == $current_site->path )
+ return true;
+ return false;
+}
+
function get_id_from_blogname( $name ) {
global $wpdb, $current_site;
if( constant( 'VHOST' ) ) {
@@ -1961,4 +1968,13 @@ function signup_nonce_check( $result ) {
}
add_filter( 'wpmu_validate_blog_signup', 'signup_nonce_check' );
add_filter( 'wpmu_validate_user_signup', 'signup_nonce_check' );
+
+function maybe_redirect_404() {
+ global $wpdb;
+ if( is_main_blog() && is_404() && defined( 'NOBLOGREDIRECT' ) && constant( 'NOBLOGREDIRECT' ) != '' ) {
+ header( "Location: " . constant( 'NOBLOGREDIRECT' ) );
+ die();
+ }
+}
+add_action( 'template_redirect', 'maybe_redirect_404' );
?>
diff --git a/wpmu-settings.php b/wpmu-settings.php
index 838c96b..3b52a02 100644
--- a/wpmu-settings.php
+++ b/wpmu-settings.php
@@ -103,12 +103,7 @@ if( constant( 'VHOST' ) == 'yes' ) {
if( defined( "WP_INSTALLING" ) == false ) {
if( $current_site && $current_blog == null ) {
- if( defined( 'NOBLOGREDIRECT' ) && constant( 'NOBLOGREDIRECT' ) != '' ) {
- header( "Location: " . constant( 'NOBLOGREDIRECT' ) . "?new=" . urlencode( $blogname ) );
- } else {
- header( "Location: http://{$current_site->domain}{$current_site->path}wp-signup.php?new=" . urlencode( $blogname ) );
- }
- die();
+ $current_blog = $wpdb->get_row("SELECT * FROM {$wpdb->blogs} WHERE domain = '{$current_site->domain}' AND path = '{$current_site->path}'");
}
if( $current_blog == false || $current_site == false )
is_installed();