Multisite, Subdomains and www
|Reported by:||jkhoffman||Owned by:|
I installed a WordPress Multisite network (in subdomain mode) on Zend's PHPCloud.com.
Zend does not provide an IP address, recommending a CNAME instead. CNAME records are not allowed on the root of a domain, so they recommend using the www subdomain, with a redirect from the root domain to www.
This site can NEVER be accessed on the naked domain; it will always be accessed via the www subdomain.
So, I setup wildcard DNS for *.mydomain.com, then created a network on www.mydomain.com. Then, I went to a non-existant subdomain on my network, nonexistant.mydomain.com, and WordPress redirected to www.mydomain.com/wp-signup.php?new=nonexistantwwwmydomaincom.
The correct behavior is to redirect to www.mydomain.com/wp-signup.php?new=nonexistant
The fix for this is in wp-includes/ms-settings.php, replace line 89 with:
$site_domain = preg_replace( '|^www\.|', '', $current_site->domain ); $destination = 'http://' . $current_site->domain . $current_site->path . 'wp-signup.php?new=' . str_replace( '.' . $site_domain, '', $domain );
Also, on the registration page at the bottom it says:
"The site you were looking for, http://nonexistant.www.mydomain.com/ does not exist, but you can create it now!"
The fix is in ms-blogs.php, line 53:
$url = preg_replace( '|^([^\.]+://)(?:www\.)?|', '$1' . $blogname . '.', $url );