Several websites in one WP folder

Joined
Apr 19, 2021
Messages
21
Likes
9
Degree
0
Hi builders,

i'm new here and want to share a snippet i use since a long time to run several websites in one WP folder.

When you open up wp-config.php you will find a line like:
PHP:
$table_prefix = 'wp_';

changing that to:

PHP:
//$table_prefix  = 'wp_';
   $table_prefix = preg_replace('/^(www\.)/', '', $_SERVER['HTTP_HOST']);
   $table_prefix = preg_replace('/\-/','', $table_prefix);
   $table_prefix = preg_replace('/\./','', $table_prefix);
   $table_prefix = $table_prefix . '_';

and pointing several different blogs to that wp folder will give you multiple blogs without the hassle of using WP Multisite or what it is called.
 
So you're using separate databases but they're all running off of one Wordpress installation, allowing you to use the same theme and plugins? Is that the point here? Pretty nifty.
 
Exactly, that is the point. When using Multisite the database structure is complicated. When using the above approach you have only one WP installation to take care of, and you can easily move single sites to a different hosting or server.

Another advantage of this setup is that you have to update only one installation.
 
Back