News:

Get Out, See Green!

Main Menu

Simple Partial Subdomain Support

Started by zourtney, May 20, 2008, 09:53 PM

Previous topic - Next topic

zourtney

We're still working on a good setup, but this very simple tweak to wp-config allows you to drop the whole Wordpress installation into another directory. When you run it for the first time, it'll set up the database by prepending the subdomain name.

We decided to prepend all "www" database tables with an underscore. All subdomains will be the subdomain name plus the underscore. To do this you only need to change three files.

Find /wp-config.php.
Change the following from:

// You can have multiple installations in one database if you give each a unique prefix
//$table_prefix  = 'wp_';   // Only numbers, letters, and underscores please!


To:

$table_prefix = ereg_replace( '^(www\.)', '', $_SERVER['HTTP_HOST'] );
$table_prefix = ereg_replace( 'yourserver.com', '', $table_prefix );
$table_prefix = ereg_replace( '\.', '_', $table_prefix );


Now the root site will prepend the tables with and underscore. All subdomains will be prepended with the sobdomain  name and an underscore.

All done!