How to create a network of top level domains with WordPress 3.0

By Matt Dunlap on June 18th, 2010 5 comments
Tags: , , ,

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:

Virtual Directories

After:

virtual directories

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.

Insert new siteThis 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


My next post is going to be awesome... Subscribe to my feed so you don't miss it

Large RSS Feed Button


Previous Post Next Post

5 Responses to How to create a network of top level domains with WordPress 3.0


[...] prefer subdomains, and I’ll be posting some blog posts later on how to run WordPress with Top level domains soon. I don’t think you can do that with folders. In order to run subdomains, you need to [...]


[...] to bookmark one tutorial this year, you  should bookmark the one you’re reading now and this one. The Holy Grail for [...]

Installing Wordpress Multisite for TLDs | Bush Mackel
Comment added: 29 June, 2010 at 4:34 am

[...] thing working. What started me on the good path was Matt Dunlap’s post on the subject here: http://mattdunlap.org/website-development/wordpress/how-to-create-a-network-of-top-level-domains-wit... where he directs you to editing your httpd.conf file. I did this and I believe I got it to work, [...]

devonroma
Comment added: 21 July, 2010 at 1:43 pm

Matt, you mention “all the websites in the WordPress install can share posts, comments, categories, etc…,” but I haven’t been able to find any documentation about this for WP 3.0 Multisite. I would specifically like to be able to share posts from the primary domain with the subdomains. Do you have any insight you could share?
Thanks,
Devon

Matt Dunlap
Comment added: 21 July, 2010 at 1:54 pm

There are a couple ways to do it. Either way will require a custom plugin. I recently made a website that used a couple posts from the “main” site on all the subsites. I use the switch_to_blog($blogid) function. switch_to_blog is just how it sounds. You can call it multiple times on the same page, but it does have performance issues. Not that bad though. I have had problem with the restore_current_blog() function that you should call when you are done with working on the other blog posts. Since restore_current_blog didn’t work, I just used switch_to_blog and passed the current blog id to it. Worked fine.

Post a Comment

Name:   
Email:   
Website:   
Comments:   
alert icon Do you need help with your website? I can offer full system admin, website development and Internet marketing services
Domain Name Deals
.COM for $1.99
With any non domain name purchase
Free Private Registration - When you buy or transfer 5 domains at opendls.com
Domain Name Reseller Accounts
Low buy rates - Very Profitable
Matt Dunlap on Why am I getting redirect loop errors with FireFox 3.6.8?
Hi, thanks for the heads up... Have you experienced this problem with any other websites? It's reall[...]
Stacy on Why am I getting redirect loop errors with FireFox 3.6.8?
I was attempting to follow your links to these tutorials from your youtube video, and I was using th[...]
Matt Dunlap on 301 redirects will lower your Google Pagerank
You want 301 redirect on same site redirects mainly to eliminate duplicate content. For example, if [...]
Kate Mag on 301 redirects will lower your Google Pagerank
great info. Does this mean that only affecting 301 redirect to another domain. I have 301 redirect t[...]
Mike Johnson - Real Estate Agent on Why is making extra money a bad habit?
Hey man, this is some great stuff. The only thing I can't figure out is why this sort of thing isn'[...]

Top Guest Bloggers

LoneWolf
View Posts | RSS

Guest Bloggers Welcome!


Powered By: Free Premium WordPress Theme | Copyright 2007 - 2010 mattdunlap.org Sitemap