Most of the basic shared hosting plans will only allow you to use 1 domain name and a limited number of databases. So what do you do if you want to set up more then one WordPress powered site on your hosting plan? Here’s a solution.
Most hosts will allow you to ‘park’ or ‘forward’ additional domains to your hosting plan, but they will show the same site, they can’t be configured to show content from different places. but because the actual files of a WordPress installation are the same, and all the information is stored in the database, we can manage a workaround. What we will do is set up WordPress to use different databases depending on the domain name entered in the browser window.
You will only need to edit 1 file, so this make future updating of your WordPress installation pretty simple. In fact, even if you have your own server, this method might help you keep all your wordpress sites up to date.
Here are the simple steps:
- Upload the WordPress files to your server.
- Copy the following code to a text editor, and enter your database settings (note: you will have to delete the space between ‘< ' and '?php' in the beginning of the document.)
< ?php
// ** MySQL settings ** //
define('DB_NAME', ''); // The name of the database
define('DB_USER', ''); // Your MySQL username
define('DB_PASSWORD', ''); // ...and password
define('DB_HOST', 'localhost'); // 99% chance you won't need to change this value// table prefix, for hosting multiple intalltaions in the same db.
$table_prefix = ereg_replace('^(www\.)', '', $_SERVER['HTTP_HOST']);
$table_prefix = ereg_replace('\.', '', $table_prefix);
$table_prefix = $table_prefix . '_';// Change this to localize WordPress. A corresponding MO file for the
// chosen language must be installed to wp-includes/languages.
// For example, install de.mo to wp-includes/languages and set WPLANG to 'de'
// to enable German language support.
define ('WPLANG', '');/* Stop editing */
define('ABSPATH', dirname(__FILE__).'/');
require_once(ABSPATH.'wp-settings.php');
?> - Save the file as wp-config.php and upload to your sever (where the regular wp-config.php file normally is)
That’s it!
Now, every domain (or sub-domain) you have pointing at this WordPress installation will use a different prefix for it’s tables in the database, so they are totally different, using different settings and data stored in the database.
To add another site, just set up the domain (or sub-domain) ‘pointing’ then visit that domain and follow the wordpress installation process.
Credits: this technique is based on the more complex technique (better for hosting solutions) from OldBrownShoe.org

That’s very useful
. Thanks! Just when I was thinking about installing a second copy of Word Press for my football newsletter!
Jan/Payal
t
%
Hello,
Super! Really thanks for you hack.
I have been looking for a solution to have one wp install with differnt domains. I search wordpress.org, all their guides need to change a lot of things in order to it.
I also tried wordpress mu, but I really can’t figure it out how to have different domains(not sub domain) for different blogs.
And your hack, only need to modify the config file. It’s a really super hack! Millions thanks!
I found a problem, if I type something other than “www”, before the domain, it will shows:
It doesn’t look like you’ve installed WP yet. Try running install.php.
Will it case potential security problem? Is there any possible way I can fix it? Thanks.
hmm, i’ll look into that
this is so cool hack – thanks
[...] http://me.mywebsight.ws/2006/08/11/host-multiple-wp-sites-on-one-installation/ [...]
Say, what did you find when looking into the issue max mentions?
Thanks!
You need to configure in your apache or dns server to only accept www. Then there will be no problem.
But recently, I got another problem, I got a domain with hyphen. When I try to install wordpress, it give me error. All you have to do is to add the following line:
$table_prefix = ereg_replace(‘\-’, ”, $table_prefix);
You can just add it under $table_prefix = ereg_replace(‘\.’, ”, $table_prefix);
Hope this help.
[...] http://me.mywebsight.ws/2006/08/11/host-multiple-wp-sites-on-one-installation/ http://www.idratherbewriting.com/2007/05/31/installing-multiple-versions-of-wordpress-on-the-same-account-but-masking-them-to-appear-as-different-domains/ [...]
Really impressive!! Still better than before with the different sites! Congratulations!,
[...] Host multiple WP sites on one installation one database multiple wordpress installations (tags: wordpress mysql database) [...]
[...] verweist auf eine Anleitung, die aufzeigt, wie man mit einer Wordpress-Installation mehrere Blogs zugleich bedient. Noch ausführlicher gibts den Spaß auf Wordpress.org. weitere Artikel: « [...]
[...] ganz interessanten Link bei Schockwellenreiter via Robert gefunden, wonach man mit nur einer Wordpress Installation mehrere Blogs bedienen kann, ohne auf die spezielle Multi-Blog Version Wordpress-MU zu verwenden. Der Trick dabei [...]
[...] Host multiple WP sites on one installation- This ‘N That (tags: wordpress multiple howto) [...]
[...] Host multiple WP sites on one installation- This ‘N That Most of the basic shared hosting plans will only allow you to use 1 domain name and a limited number of databases. So what do you do if you want to set up more then one WordPress powered site on your hosting plan? Here’s a solution. (tags: wordpress software multiple database howto blogging blogs server hosting) [...]
[...] Host multiple WP sites on one installation Most of the basic shared hosting plans will only allow you to use 1 domain name and a limited number of databases. So what do you do if you want to set up more then one WordPress powered site on your hosting plan? Here’s a solution. (tags: wordpress multiple software database howto) [...]
[...] Read the rest of the post by TechJournalist [...]
Hi,
Thanks for the great job you did. this plugin is wonderful. However i was wondering if it is possible to have same user accounts for all different blogs. I want to be able to have the admin and other users login to all blogs with the same usernames and passwords. If any body have an idea, please share it. Thank you!
Thanks for a good post. I was searching for this information because I wanted another wp blog site for another niche. I will try this now and hope it works. By the way, I am already having a WP installed on one SubDomain in this format: (SubDomain1.MainDomain.com) so how should I modify any existing code to use the same installation for a different subdomain: eg. a proposed SubDomain2.MainDomain.com? Thanks again.
I will try this for a new blog topic. Hope this works. Thanks.
[...] Thought some of ya’s might like this – Host multiple WP sites on one installation- This ‘N That [...]
Thanks! By creating a wildcard dns, and then I added a “*” subdomain (in cpabel) redirecting to my base domain. Now with your tip I have unlimited (subdomainbased) wp instances! Cool buddy.
[...] Host multiple WP sites on one installation- This ‘N That but I don’t know php and I’m not sure how this is going to work. Do I just install a new copy of [...]
Superb and easy man, thanx a lot…..
I ll add a link to this page on my blog….
I have been doing something similar to this for some time however unless i am missing something, i believe that your method introduces a potentially significant security exposure.
I think i am right in saying that it’s possible that using this method someone could point their domain to your server and start using your server to host their site.
I’d start by hosting a new site, I could then get into the theme editor using the administrator id that gets set up by WP on installation. I would then start hacking into your themes and injecting some code in there that I can use to read and write to your database for all of your hosted sites.
What i would recommend to avoid this is coding something like this:
switch ($_SERVER['HTTP_HOST']) {
case “www.mydomain1.com”:
case “www.mydomain2.com”:
case “subdomain.mydomain2.com”:
$table_prefix = ereg_replace(‘^(www\.)’, ”, $_SERVER['HTTP_HOST']);
$table_prefix = ereg_replace(‘\.’, ”, $table_prefix);
$table_prefix = $table_prefix . ‘_’;
break;
default:
$table_prefix = “default_’;
}
Change default_ to be your default_ site – this is the key that stops unknown domains making a new wordpress site on your server without your knowledge.
yes, it requires a little extra maintenance – editing the one file – whenever you add a new domain or subdomain but this is not significant – you would simply add another case line containing the domain name.
I’m trying to get this to work locally so there is no www prefix. I’ve got wordpress in /wp/ and can setup virtual alias’ /apple/ /banana/ etc. but can’t get them to be recognised by $_SERVER. $_SERVER['REQUEST_URI'] seems to work, slashes taken out et al but wordpress exclaims that their is something besides letters , numbers and under-slashes in the table prefix. Thoughts?
[...] was that possible without going down the MU route? The answer is that not only is it possible, but it’s also rather easy. I made a modification to my wp-config.php file that appends a host name prefix to every WP table [...]
[...] links that may be useful for you: Wordpress 2 Multi-Blogging Made Easy Host Multiple WP Sites On One Installation Installing Multiple Versions Of Wordpress On The Same Account But Masking Them To Appear As [...]
Is it possible to create two wordpress blogs like this.
http://blog.karthikeyan.co.in/
http://blog.karthikeyan.co.in/blog2/
While this is good, it doesn’t solve the issue fully.
What is needed is to use one simple backend, where by you can add / edit / delete domains.
You can also select which categories / posts belong to which domains.
Each domain is then set via apache2 httpd.conf to pull from the same documentroot. The WP installation then determines which site your on from the SERVER_NAME as pulls the relevant theme / posts / categories.
Can someone pls explain further how to do the domain ‘pointing’? Thanks!!
Is domain pointing the same as the “Redirect Domain to URL” option under the Addon Domain Maintenance in the cpanel?
[...] war der Betrieb mehrerer Wordpress-Blogs, die parallel gepflegt werden mussten. Dank eines Tipps von Sebastian konnte ich nun einfach Abhilfe [...]
Why not just use the wordpress MU? This is a multiuser version of wordpress.
The same used on wordpress.com.