Killed My Blog (WordPress 3 MU)

I completely destroyed one of my sites after upgrading to WordPress 3 and activating the Multisite (MU) feature… With all my post links broken, messed up permalinks and 302 redirects springing up left and right…

I remembered what ol’ Cesar Serna does when the earth quakes, and the poison arrows fall from the sky, and the pillars of Heaven shake. Yeah, Cesar Serna just looks that big ol’ storm right square in the eye and he says, “Give me your best shot, pal. I can take it.”

Or was that Jack Burton…?

Here is what happened… I had and existing blog and upgraded it to WordPress 3 using the Upgrade WordPress button in the admin dashboard.

Then I added the following line to my wp-config.php file:

define( 'MULTISITE', true );

This activates a new link called “Networks” within the admin area of WordPress… Tools->Networks… In here is where you upgrade a standard blog to use the new Multisite (MU) features…

How I screwed things up…

Here is where it gets screwy and WP completely drops the ball when converting existing blogs…

Screw up #1… WP3 requires existing blogs activating the new MU feature to use “SUBDOMAINS”… for some reason it cannot do sub-directory type blogs…

Screw up #2… WP3 suggests you switch to non-www domain… so I did…

Screw up #3… I clicked upgrade and committed the changes… yay!

Here is what I did to fix what broke…

Fixing permalinks… As it turns out WP3 decided to mess with my permalinks… oh yeah… just changed all of my permalinks… Even though it knew it was an existing blog upgrade… not that this would impact anything important… like say, I don’t know… indexed content in search engines and backlinks!!! WP3 used a 302 redirect for every post and sent it to the homepage… Thanks WP!

Here is how I fixed it…

  1. Opened phpMyAdmin to my WordPress DB
  2. Clicked on the wp_blogs table and added www to the domain
  3. Clicked on the wp_options table and added www to the domain for “home” and “siteurl” option
  4. Also changed the “permalink_structure” field back to my original setting “/%category%/%postname%/”
  5. Clicked on the wp_site table and added www to the domain
  6. Clicked on the wp_sitemeta table and added www to the domain in “siteurl” field

Opened the wp-config.php file and changed the “define( ‘SUBDOMAIN_INSTALL’, true );” to “define( ‘SUBDOMAIN_INSTALL’, false );”… also added the www to the domain name here… see below example…

define( 'MULTISITE', true );
define( 'SUBDOMAIN_INSTALL', false );
$base = '/';
define( 'DOMAIN_CURRENT_SITE', 'www.domain.com' );
define( 'PATH_CURRENT_SITE', '/' );
define( 'SITE_ID_CURRENT_SITE', 1 );
define( 'BLOG_ID_CURRENT_SITE', 1 );

But things were still not well… you see WP3 MU decided that it needed to hard code “/blog/” to the beginning of all my blog post urls (it does this for the main blog only)… WP3 MU currently has no way to disable this… WordPress Devs either don’t care or don’t get that changing all established URL’s will seriously screw my site up…

Of course I did what any rational person would do… I modified the core files… just one… ;)

In the “/wp-admin/options-permalink.php”… starting on line 94… I removed the hard coded “/blog”…

BEFORE:

if ( is_multisite() && !is_subdomain_install() && is_main_site() )
        $blog_prefix = '/blog';

AFTER:

if ( is_multisite() && !is_subdomain_install() && is_main_site() )
        $blog_prefix = '/';

One more change… Remember how in the “UPGRADE” WP3 MU forced me to go to sub domains instead of sub directory? Well it installs the sub-domain .htaccess code and at this point I need the sub-directory code… here is the code for sub-directory…

RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
 
# uploaded files
RewriteRule ^([_0-9a-zA-Z-]+/)?files/(.+) wp-includes/ms-files.php?file=$2 [L]
 
# add a trailing slash to /wp-admin
RewriteRule ^([_0-9a-zA-Z-]+/)?wp-admin$ $1wp-admin/ [R=301,L]
 
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
RewriteRule  ^([_0-9a-zA-Z-]+/)?(wp-(content|admin|includes).*) $2 [L]
RewriteRule  ^([_0-9a-zA-Z-]+/)?(.*\.php)$ $2 [L]
RewriteRule . index.php [L]

As you can see the code for “Sub Directories” shown above is just a bit different from the “Sub Domain” .htaccess code WP installed shown below…

RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
 
# uploaded files
RewriteRule ^files/(.+) wp-includes/ms-files.php?file=$1 [L]
 
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
RewriteRule . index.php [L]

All fixed and working… Thanks WP! (yea right…)

So after getting my blog back online and everything working as before I decided to test the new MU feature… I created a new blog and you know what? sub-directory blogs work just fine… even without the “/blog” WP hardcoded in the core file…

WP3 Devs take note… There is no need to force existing blogs to use “subdomains” or screw up existing posts with new permalinks and hardcoding “/blog”…

Just when the average coder would have thrown in the towel, I pulled it out in record time… reminds me of something I always say at a time like this…

When some wild-eyed, eight-foot-tall maniac grabs your neck, taps the back of your favorite head up against the barroom wall, and he looks you crooked in the eye and he asks you if ya paid your dues, you just stare that big sucker right back in the eye, and you remember what ol’ Cesar Serna always says at a time like that: “Have ya paid your dues, Cesar?” “Yessir, the check is in the mail.”

Join My Newsletter

Receive tips on business, iOS Development and WordPress.
Learn more about me and my experiences online.







Comments

  1. I have a similar problem, thankfully i updated to 3.0 in a domain i use for testing. I do not understand why you added www. to all the url, i’m not a coder either, ill try your suggestions and i hope it works,

    no subdomains work, and i wanna create website as subdirectories,

    I’m on 1and1 so i don’t know if that causes the problem, but im looking to find the way around it.

    best, thanks for the info!

  2. Hey Spyro,

    The site was originally setup many years ago (before the movement by WordPress to go with non-www) and once I upgraded I found that WP3 was not auto redirecting www to non-www… instead it was just redirecting everything to the homepage… not a good thing…

    Hosting companies are bit weird when it comes to subdomains… what you want to ask for is “Wildcard DNS” so all subdomains are handled by WordPress…

    When you talk to your hosting company make sure to tell them that you are NOT going to be hosting blogs… they do not (for business reasons) want to increase server load without making money…

    HTH
    -Cesar

  3. ok i see,

    So i don’t have to add www.

    i can not set up a wildcard dns cause 1and1 can not create subdomains with * … so thats forgotten

    I’m clueless when it comes to hosting corporate websites, i have a business plan with 1and1 and I assume its ok , altho, im not quite sure.

    i assume if i follow your instructions i will be able to create “blogs” with permalinks such as domain.com/whatever , right?! thanks for your response,

    It seems difficult to find the answers online, wp 3.0 is still new and I often can’t find others who posted for the same problem.

    best

  4. Hey Spyro,

    If you follow what I did above… your main blog permalink structure will be like this:

    http://www.domain.com/post-name

    and not

    http://www.domain.com/blog/post-name < -- WP3 Default

    Plus when you setup user blogs they will appear like this:

    http://www.domain.com/blogname/post-name

    I would suggest you check out this plugin for MU:

    http://wordpress.org/extend/plugins/wpmu-new-blog-defaults/

    It enables you to set the defaults for all new blogs created… makes it much easier to keep consistent settings across multiple semi-monitored blogs…

    Let me know if you have anymore questions…

    HTH
    -Cesar

  5. thanks for being so helpful.

    It was very easy to make it work, thank you for this tutorial.

    I have some more problems that puzzle me,

    any way that i can feature any blog post from any blog (site) on my network to the main website? for example, can i take a blog post from the back end and move it to other back end?

    The Independent newspaper has something close to what i need http://blogs.independent.co.uk/

    Also, any plugin to display related posts below the posts of across the network?

    gimme your lights, any plugins and any way around my issues know please let me know,

    thank you again,

  6. Thanks for this. I just ran into a similar situation.

    We only need to change:
    $blog_prefix = ”;

    BTW, there is an annoying piece of javascript code on this comment box, that if you leave the page (like to copy some text to paste in), and then return to click to paste it, it wipes your original message.

    Thanks

  7. Hi Brian,

    Glad I could help…

    I’m testing out this new theme… so far not so happy with it…

    sometimes designers should stick with what they do best and leave coding to coders… :)

  8. OK…you obviously know what you’re doing…so…perhaps you can help me out. I was asked to take the main portion of this site off the WP platform and install WP into a folder on the site. Done…finally. Static pages working…blog working in its folder…but…for some reason the original designer coded links into the home page flash which of course I didn’t realize until everything else was done…drats. NOW since I don’t work with flash I have a problem that sounds sort of like yours. The links originally were coded to go to domain.com/?page_id=41 for instance. When the links are clicked you are redirected to the home page…I’ve tried 404 page…doesn’t work…tried to redirect myself…doesn’t work. I looked at the database files you mentioned but I’m just not good enough to get into those areas (and I don’t see where to change the urls anyway). I don’t need to make the problem worse. Any ideas to help with this problem?

Speak Your Mind

*