diff --git a/wp-admin/network.php b/wp-admin/network.php
index 7a842b4b10..08ea513efb 100644
--- a/wp-admin/network.php
+++ b/wp-admin/network.php
@@ -36,6 +36,19 @@ function network_domain_check() {
return false;
}
+/**
+ * Allow subdomain install
+ *
+ * @since 3.0.0
+ * @return bool - whether subdomain install is allowed
+ */
+function allow_subdomain_install() {
+ $path = preg_replace( '|https?://[^/]|', '', get_option( 'siteurl' ) );
+ if( strlen( $path ) > 1 || 'localhost' == $_SERVER[ 'HTTP_HOST' ] )
+ return false;
+
+ return true;
+}
/**
* Get base domain of network.
*
@@ -134,7 +147,7 @@ function network_step1( $errors = false ) {
echo '
' . __( 'If mod_rewrite
is disabled, ask your administrator to enable that module, or look at the Apache documentation or elsewhere for help setting it up.' ) . '
';
}
- if ( 'localhost' != $hostname ) : ?>
+ if ( allow_subdomain_install() ) : ?>
You cannot change this later.' ); ?>
@@ -175,6 +188,11 @@ function network_step1( $errors = false ) {
|
localhost, the sites in your WordPress network must use sub-directories. Consider using localhost.localdomain if you wish to use sub-domains.'); ?> |
+
+
+ |
+ |
+
@@ -217,7 +235,7 @@ function network_step2( $errors = false ) {
echo '' . $errors->get_error_message() . '
';
if ( $_POST ) {
- $vhost = 'localhost' == $hostname ? false : (bool) $_POST['subdomain_install'];
+ $vhost = !allow_subdomain_install() ? false : (bool) $_POST['subdomain_install'];
} else {
if ( is_multisite() ) {
$vhost = is_subdomain_install();
@@ -326,7 +344,7 @@ if ( $_POST ) {
// create network tables
install_network();
$hostname = get_clean_basedomain();
- $subdomain_install = 'localhost' == $hostname ? false : (bool) $_POST['subdomain_install'];
+ $subdomain_install = !allow_subdomain_install() ? false : (bool) $_POST['subdomain_install'];
if ( ! network_domain_check() ) {
$result = populate_network( 1, get_clean_basedomain(), sanitize_email( $_POST['email'] ), $_POST['sitename'], $base, $subdomain_install );
if ( is_wp_error( $result ) ) {