How to create a network of top level domains with WordPress 3.0
| By Matt Dunlap on June 18th, 2010 | 5 comments |
WordPress 3.0 has merged WPMU with WP and now everyone that has a self hosted blog can make multiple websites. Many hosting providers offer multiple domain name hosting in the form of parking websites, but sometimes that is just not what you want.
Cheap hosting accounts, will usually only allow you to point domain names to your main domain, so you can’t really run multiple websites. More expensive hosting accounts will allow you to park a domain, but it is usually not associated with any other websites on your host.
I like using WordPress to manage all the sites because all the websites in the WordPress install can share posts, comments, categories, etc… Not to mention, just being really easy to use WordPress
If you haven’t set up WordPress 3.0 to create a network, follow this tutorial I made.
Once it is set up, you should have your main domain name, and you should have at least one subdomain created. We are now going to turn that subdomain into a top level domain.
I will be turning the subdomain, matt.hit6.com into digital-camera-advice.com
Step 1 – Add the new domain to the virtual directory of your wordpress install.
you will need to edit your httpd.conf file for this.
Before:

After:

Notice I added a wildcard to digital-camera-advice.com – This will allow me to build another network of it. You can see it can go on and on, making many communities.
Save it and restart Apache. Then go to the new domain name in your browser and you should land on you new WordPress install, in this case hit6.com
Step 2 – Set up WordPress Database
You are going to be working with the wp_site, wp_blogs, and wp_x_options table. x = the blog id. Each new subdomain you make in WordPress will get it’s own database tables, designated with a table prefix of wp_<id>_
In this example, I have only one subdomain so the option table I will be working in is wp_2_options. You need to change the domain name in three fields, from matt.hit6.com to digitial-camera-advice.com. The three fields are siteurl, Home, and fileupload_url.
That’s all you have to do in wp_2_options.
Now onto the wp_site table. There is no id prefix for this table. You need to do an insert, basically making a new site.
This isn’t a sql tutorial, so if you have problems or don’t understand how to do an insert, just contact me and I’ll help you.
After you make the site, you will need to remember the new site id. in this example it is 2.
Now go to wp_blogs and update the entry for matt.hit6.com. Again, change the domain name and also update the site_id to 2. The site id for the domain names must match. If they don’t you will not be able to log into the admin section for the new websites.
Finally, you need to run a sql query that copies all the sitemeta from the main site and adds it for the new domain name. There are a lot of fields, so just run this:
INSERT INTO wp_sitemeta (site_id, meta_key, meta_value) SELECT <THE_NEW_SITE_ID>, meta_key, meta_value FROM wp_sitemeta WHERE site_id = 1
That’s it for the database. Now, go back to the WordPress admin section. Before there was 2 blogs listed. If you refresh the page, matt will disappear. It is now a new site and you can’t access it from other sites, unless you write a script to display all sites. You can will only see blogs (subdomains) of sites.
You need to go to the new site and access the admin section from the new site. You will need to login to each site, unless you set a cookie, but the cookie is only for that site. It makes it a little hard when you run multiple sites.
As always, let me know if you have any questions or comments, good luck




Post a Comment