Question from a Reader: Hosting multiple WordPress blogs on one domain name – Part 2
Mike writes: So I'm a newbie when it comes to wordpress, but I think I can catch on fairly quickly. what I was hoping to find was something that would teach me to have one domain name, and have multiple blogs on that domain name, however, have a main front page, that would have that blog orginized into various preview posts.
This part of the question is significantly more difficult to deal with, since WordPress doesn't offer this functionality (at least not in any way I'm familiar with!)
Mike pointed out a site called iBankCoin.com that had a front page concept similar to what he was trying to accomplish. The site, like many others out there, aggregated content from different sections (or different sub-sites) into one entry page. The layout is fixed, but the content is populated by whatever is most recent in the given section.
The 'Peanut Gallery' section could be a sub-site WordPress blog, where authors are Contributing users on that blog.
There are going to be two main technologies to pulling something like this off:
- RSS, or Really Simple Syndication, is an XML format that publishes the content of a website stripped of any styling, so that it can be simply consumed and read by other software -- like a news reader or aggregator.
- PHP is the server-side programming language that WordPress uses to publish your blog content. Because WordPress uses it, we know that its installed on the server. There are other languages, such as ASP, that could accomplish the same thing, but there's no guarantee that those will be available on your server.
In short -- and I'm not going to be able to expand a whole lot without actually writing the code -- we can use PHP and HTML to create our front page. Even basic HTML can do the layout we're looking to borrow. We'll use PHP, which runs on the server before the page is served up to the viewer, to populate the content of the page by pulling the RSS feed from each sub-site.
The RSS part of the puzzle is, by far, the easiest. WordPress has RSS publishing built right in, and if you have a WordPress blog up and running, so is your RSS feed! Just add /feed to the end of your WordPress URL.
So, using our previous examples, if we had a sub-site called www.jwcars.com/red-cars we could get the latest posts from it in RSS format by going to www.jwscars.com/red-cars/feed
The Entry Page, then, will be where the smarts of our system go. This page will contain both the HTML necessary to define the layout, and the PHP necessary to retrieve the RSS from each site, parse it, to extract only the information we want, then push it into the HTML as the page is loaded.

There are lots of ways we can do this, making it more intelligent (and complex) and there are lots of principles of good programming that would probably come in useful, but to keep things simple, here's what's going to happen at a minimum:
An HTML page exists on the server, with the special extension .php (for example, index.php works on most servers as a default page)
Before the HTML code, but in the same document, we'll have a block of PHP code, called a method, that knows how to fetch RSS, single out the text we want, format it, and send it back:
<?php
// work your magic
?>
<html>
Your page goes here
</html>
Within the HTML code, in the places where we want the external content to appear, we'll call that PHP method, telling it what RSS feed to retrieve:
<?php
// work your magic
?>
<html>
Your page goes here
<span>
<?php //request magic trick ?>
</span>
</html>
When the user pulls up the entry page of our site, the server will read through the .php file, find all the places where it needs to do some work, and execute our code, returning the results to our visitor as a completed HTML page, with all the PHP code gone:
<html>
Your page goes here
<span>
MAGIC!
</span>
</html>
Now I know this is hardly a complete solution. In fact, there are probably a number of ways to solve this problem, and this is merely a sketch of one way to deal with it. But one of the huge advantages to using PHP is that its a well loved little scripting language, and for anything you want to do, odds are, someone has already done it, or something similar, and published a how-to, or even better yet, a Library you can download, and use in your own code.
Case in point: by far the trickiest part of this project would be writing the code that gets and parses the RSS feed -- its an easy to understand format, but you'd still have to write a lot of code to get at what you want. Fortunately, someone's already done it. You can use Magpie RSS to handle all the difficult work for you, and you can reverse engineer this example of creating a more generic RSS Aggregator to fit your needs.
Picking up a new programming language can seem daunting at first -- as far as I'm concerned, PHP has one of the most eccentric and ugly syntaxes I've ever seen -- but Google makes for a great resource. Borrow, reverse engineer, and plaguerize any code you find published... that's how every programmer I've ever met got their start!
Question from a Reader: Hosting multiple WordPress blogs on one domain name – Part 1
Mike writes: So I'm a newbie when it comes to wordpress, but I think I can catch on fairly quickly. what I was hoping to find was something that would teach me to have one domain name, and have multiple blogs on that domain name, however, have a main front page, that would have that blog orginized into various preview posts.
So this is a relatively easy job, but it should be noted that there are probably numerous ways to accomplish what Mike is after. His problem really is in two parts, so I'll offer my solution to one, and later, some ideas at how to solve the other...
The good news is, WordPress is made to do this. In fact, I'd wager there's already some documentation on their site on how to do it. Its worth discussing though, just to get ideas flowing.
Probably the first thing you'll want to do is come up with a naming strategy for your sub-sites. Do you want to use www.mysite.com/subsite1 or do you want subsite1.mysite.com? Actually it doesn't matter from an installation perspective, but its certainly a useability concern, and one approach will dictate some additional work with your hosting provider.
Here's a screen shot of the top level web directory of a website. You can see each of my subsites, as well as some supporting folders for the entry level site...

I chose a naming convention that reverses the domain names, simply because the sort order makes it easier for me to find things. Note that in the subdomain approach (subsite1.mysite.com) the folder names don't really matter -- I'm going to hide them from users. If I chose a subfolder approach (mysite.com/subsite1) the folder names would be important (at least in a simple setup).
In Mike's case, the entry site (or root site, or main site) will not contain a WordPress installation. This is because what he wants to do can't be done by WordPress (see part 2.) In my case, the root site doesn't contain a WordPress install either, but through some magic I'll discuss later, the top domain redirects to a WordPress-driven sub-site
Note, for interests sake, that I can also host sites with unrelated domain name is the same manor. For example, my parent's site, www.spwise.com, bounces off my server -- it currently just redirects to another site, but I host the domain name.
Ok, now if all of that is as clear as mud, here's where it gets easy. Download the latest WordPress zip archive, unzip it, and upload it as many times as you want to your server -- one for each subsite you want to have. Just make sure you rename the "Wordpress" folder each time, to avoid over-writing it.
So if I wanted to make the site www.jwcars.com and have the following subsites www.jwcars.com/blue-cars, www.jwcars.com/red-cars, www.jwcars.com/green-cars, I'd upload the WordPress folder 3 times, and rename the folders to blue-cars, red-cars and green-cars. Your web root folder would look something like this...

Each folder is a separate and complete WordPress installation
Now use your browser to go to the WordPress install page in each of those folders, and set-up the sites. At this point, each of the sites should have its own set-of tables in your WordPress database. You can share registration/log-in information between the sites, by doing a little hacking in the WordPress code -- that's outside of the scope of this write-up, but you'll find some tips on sharing config tables between multiple blogs here.
If you want to use the subdomain approach, you'll need a decent web hosting provider that lets you have access to some more advanced stuff. I'd imagine all the good ones let you do this, but I use WestHost and have been very happy with how much they let me configure on my own. Here's how I configure a subdomain on my server. You'll need to do something similar, but the exact steps will vary by service provider...

Here I point the subdomain testblog to the server path /var/www/html/com.server.testblog
You now have n number of websites running on one server. The only problem is, there's nothing running on your entry site. If people go to www.jwcars.com/blue-cars everything looks great. But if they go to www.jwcars.com they'll get a 404 error, or worse.
In part 2, we'll discuss some ideas for how the entry site might work. Its considerably more complicated, and requires a lot more custom coding, so I won't be able to provide the actual solution, but WordPress offers enough functionality to get us off on the right foot...