From 08e516d87f90728070af0a6e9182e8457e8d1543 Mon Sep 17 00:00:00 2001 From: donncha Date: Mon, 12 Mar 2007 14:40:14 +0000 Subject: Don't auto-redirect to non-www hostname Strip "www." from all urls Added "no www" page to install Can now install from url starting with "www." git-svn-id: http://svn.automattic.com/wordpress-mu/trunk@912 7be80a69-a1ef-0310-a953-fb0f7c49ff36 --- htaccess.dist | 3 --- index-install.php | 81 +++++++++++++++++++++++++++++++------------------------ wpmu-settings.php | 79 ++++++++++++++++++++++++++++------------------------- 3 files changed, 88 insertions(+), 75 deletions(-) diff --git a/htaccess.dist b/htaccess.dist index 064d236..0f14905 100644 --- a/htaccess.dist +++ b/htaccess.dist @@ -1,9 +1,6 @@ RewriteEngine On RewriteBase BASE/ -# Rewrite www.domain.com to domain.com -RewriteCond %{HTTP_HOST} ^www\.(.*) -RewriteRule ^(.*) http://%1/$1 [R,L] #uploaded files RewriteRule ^(.*/)?files/$ index.php [L] diff --git a/index-install.php b/index-install.php index 6ba9c8d..b34c8c4 100644 --- a/index-install.php +++ b/index-install.php @@ -10,20 +10,13 @@ if( $_SERVER[ 'HTTP_HOST' ] == 'localhost' ) { define('WP_INSTALLING', true); function printheader() { - if( substr( $_SERVER[ 'SERVER_NAME' ], 0, 4 ) == 'www.' ) { - $url = 'http://' . str_replace( 'www.', '', $_SERVER[ 'SERVER_NAME' ] ) . $_SERVER[ 'REQUEST_URI' ]; - print "WordPress MU Installer"; - print "

Warning! WordPress MU must be installed without the 'www.' in the URL.
Please click here to continue the install: $url

"; - die(); - } - print ' +?> WordPress › Installation

WordPress MU

-'; +

Blog Addresses

Please choose whether you would like blogs for the MU install to use sub-domains or sub-directories. You can not change this later. We recommend sub-domains.

-


-

+


+

Database

@@ -252,38 +245,39 @@ function printstep1form( $dbname = 'wordpress', $uname = 'username', $pwd = 'pas - + - + - + - +
Database Name
User Name
Password
Database Host

Server Address

-

+

Blog Details

- + - +
Weblog Title What would you like to call your weblog?
Email Your email address.

-
"; + + - -

To finish setting up your blog, please fill in the following form and click Submit.

- - -
- You will be sent an email with your password and login links and details."; -} - function step3() { global $wpdb, $current_site; $base = stripslashes( dirname( $_SERVER["SCRIPT_NAME"] ) ); @@ -420,14 +402,43 @@ We hope you enjoy your new weblog. print "

Congrats! Your WPMU site has been set up and you have been sent details of your login and password in an email.

"; } +function nowww() { + $nowww = str_replace( 'www.', '', $_POST[ 'basedomain' ] ); + ?> +

No-www

+

WordPress MU strips the string "www" from the URLs of sites using this software. It is still possible to visit your site using the "www" prefix with an address like but any links will not have the "www" prefix. They will instead point at .

+

The preferred method of hosting blogs is without the "www" prefix as it's more compact and simple.

You can still use "" and URLs like "www.blog1." to address your site and blogs after installation but internal links will use the format.

+

www. is depreciated has a lot more information on why 'www.' isn't needed any more.

+

+ '> + '> + '> + '> + '> + '> + '> + + + +

+ hide_errors(); -$sites = $wpdb->get_results( "SELECT * FROM $wpdb->site" ); // usually only one site -if( count( $sites ) == 1 ) { - $current_site = $sites[0]; - $path = $current_site->path; -} - -if( isset( $current_site ) == false ) { +function wpmu_current_site() { + global $wpdb, $current_site, $domain, $path, $sites; $path = substr( $_SERVER[ 'REQUEST_URI' ], 0, 1 + strpos( $_SERVER[ 'REQUEST_URI' ], '/', 1 ) ); if( constant( 'VHOST' ) == 'yes' ) { $current_site = $wpdb->get_row( "SELECT * FROM $wpdb->site WHERE domain = '$domain' AND path='$path'" ); - if( $current_site == null ) { - $current_site = $wpdb->get_row( "SELECT * FROM $wpdb->site WHERE domain = '$domain' AND path='/'" ); - if( $current_site == null ) { - $sitedomain = substr( $domain, 1 + strpos( $domain, '.' ) ); - $current_site = $wpdb->get_row( "SELECT * FROM $wpdb->site WHERE domain = '$sitedomain' AND path='$path'" ); - if( $current_site == null ) { - $path = '/'; - $current_site = $wpdb->get_row( "SELECT * FROM $wpdb->site WHERE domain = '$sitedomain' AND path='$path'" ); - if( $current_site == null && defined( "WP_INSTALLING" ) == false ) { - if( count( $sites ) == 1 ) { - $current_site = $sites[0]; - die( "That blog does not exist. Please try http://{$current_site->domain}{$current_site->path}" ); - } else { - die( "No WPMU site defined on this host. If you are the owner of this site, please check Debugging WPMU for further assistance." ); - } - } - } + if( $current_site != null ) + return $current_site; + $current_site = $wpdb->get_row( "SELECT * FROM $wpdb->site WHERE domain = '$domain' AND path='/'" ); + if( $current_site != null ) { + $path = '/'; + return $current_site; + } + $sitedomain = substr( $domain, 1 + strpos( $domain, '.' ) ); + $current_site = $wpdb->get_row( "SELECT * FROM $wpdb->site WHERE domain = '$sitedomain' AND path='$path'" ); + if( $current_site != null ) + return $current_site; + $current_site = $wpdb->get_row( "SELECT * FROM $wpdb->site WHERE domain = '$sitedomain' AND path='/'" ); + if( $current_site == null && defined( "WP_INSTALLING" ) == false ) { + if( count( $sites ) == 1 ) { + $current_site = $sites[0]; + die( "That blog does not exist. Please try http://{$current_site->domain}{$current_site->path}" ); } else { - $path = '/'; + die( "No WPMU site defined on this host. If you are the owner of this site, please check Debugging WPMU for further assistance." ); } + } else { + $path = '/'; } } else { $current_site = $wpdb->get_row( "SELECT * FROM $wpdb->site WHERE domain = '$domain' AND path='$path'" ); - if( $current_site == null ) { - $path = '/'; - $current_site = $wpdb->get_row( "SELECT * FROM $wpdb->site WHERE domain = '$domain' AND path='$path'" ); - if( $current_site == null && defined( "WP_INSTALLING" ) == false ) { - $sites = $wpdb->get_results( "SELECT * FROM $wpdb->site" ); - if( count( $sites ) == 1 ) { - $current_site = $sites[0]; - die( "That blog does not exist. Please try http://{$current_site->domain}{$current_site->path}" ); - } else { - die( "No WPMU site defined on this host. If you are the owner of this site, please check Debugging WPMU for further assistance." ); - } + if( $current_site != null ) + return $current_site; + $current_site = $wpdb->get_row( "SELECT * FROM $wpdb->site WHERE domain = '$domain' AND path='/'" ); + if( $current_site == null && defined( "WP_INSTALLING" ) == false ) { + if( count( $sites ) == 1 ) { + $current_site = $sites[0]; + die( "That blog does not exist. Please try http://{$current_site->domain}{$current_site->path}" ); + } else { + die( "No WPMU site defined on this host. If you are the owner of this site, please check Debugging WPMU for further assistance." ); } + } else { + $path = '/'; } } + return $current_site; +} + +$wpdb->hide_errors(); +$sites = $wpdb->get_results( "SELECT * FROM $wpdb->site" ); // usually only one site +if( count( $sites ) == 1 ) { + $current_site = $sites[0]; + $path = $current_site->path; +} else { + $current_site = wpmu_current_site(); } -- cgit