| | 119 | } elseif ( empty( $current_blog ) && ! defined( 'WP_INSTALLING' ) ) { |
| | 120 | // A network is available, but we have not found the requested site on the network. Redirect if possible. |
| | 121 | // @todo site_not_found action to provide custom redirect. see #21143 |
| | 122 | if ( is_subdomain_install() ) { |
| | 123 | // In a subdomain with closed registration, administrators are instructed to set |
| | 124 | // NOBLOGREDIRECT to redirect visitors who visit an invalid subdomain. If this |
| | 125 | // is not set, we assume a redirect to wp-signup.php is intentional. |
| | 126 | if ( defined( 'NOBLOGREDIRECT' ) ) { |
| | 127 | if ( '%siteurl%' === NOBLOGREDIRECT ) { |
| | 128 | // network_home_url() is not available to us yet. |
| | 129 | $destination = "http://" . $current_site->domain . $current_site->path; |
| | 130 | } else { |
| | 131 | $destination = NOBLOGREDIRECT; |
| | 132 | } |
| | 133 | } else { |
| | 134 | $destination = 'http://' . $current_site->domain . $current_site->path . 'wp-signup.php?new=' . str_replace( '.' . $current_site->domain, '', $domain ); |
| | 135 | } |
| | 136 | header( 'Location: ' . $destination ); |
| | 137 | exit; |
| | 138 | } elseif ( 0 !== strcasecmp( $current_site->domain, $domain ) ) { |
| | 139 | // If a subdomain was requested for a subdirectory configuration and could not be found, |
| | 140 | // or if an unfound domain was requested for a subdirectory configuration and could not |
| | 141 | // be found on the single network, redirect to the network's primary domain and path. |
| | 142 | header( 'Location: http://' . $current_site->domain . $current_site->path ); |
| | 143 | exit; |
| | 144 | } |
| | 145 | |
| | 146 | // Multiple networks exist in a subdirectory installation and the requested |
| | 147 | // domain does not match a site on any of them. |
| | 148 | ms_not_installed(); |
| 133 | | // If we haven't figured out our site, give up. |
| 134 | | if ( empty( $current_blog ) ) { |
| 135 | | if ( defined( 'WP_INSTALLING' ) ) { |
| 136 | | $current_blog->blog_id = $blog_id = 1; |
| 137 | | |
| 138 | | } elseif ( is_subdomain_install() ) { |
| 139 | | // @todo This is only for an open registration subdomain network. |
| 140 | | if ( defined( 'NOBLOGREDIRECT' ) ) { |
| 141 | | if ( '%siteurl%' === NOBLOGREDIRECT ) { |
| 142 | | $destination = "http://" . $current_site->domain . $current_site->path; |
| 143 | | } else { |
| 144 | | $destination = NOBLOGREDIRECT; |
| 145 | | } |
| 146 | | } else { |
| 147 | | $destination = 'http://' . $current_site->domain . $current_site->path . 'wp-signup.php?new=' . str_replace( '.' . $current_site->domain, '', $domain ); |
| 148 | | } |
| 149 | | header( 'Location: ' . $destination ); |
| 150 | | exit; |
| 151 | | |
| 152 | | } else { |
| 153 | | if ( 0 !== strcasecmp( $current_site->domain, $domain ) ) { |
| 154 | | header( 'Location: http://' . $current_site->domain . $current_site->path ); |
| 155 | | exit; |
| 156 | | } |
| 157 | | ms_not_installed(); |
| 158 | | } |
| 159 | | } |
| 160 | | |