One of our clients wanted two sites—two URLs, two designs, two sets of content—on a single WordPress install. They wanted to be able to log into a single admin area to manage both sites, and to be able to make posts of certain categories show up on both sites, while other posts would be limited to just one or the other.
I found my solution in rewrites. Users visit a url such as “example1.com/about” or “example2.com/about”, and I rewrite it so WordPress treats it as “example1.com/example1/about” or “example1.com/example2/about” without the user knowing the difference. I tried three different options before stumbling on one that worked well.
Didn’t work. Why? Because WordPress is expecting queries to be directed to index.php, and then it looks at REQUEST_URI to figure out how to dispatch the request. I couldn’t find a way to change REQUEST_URI with an apache rewrite without directing the request away from WordPress.
2) WordPress rewrite_rules
I got this working, but it was punishingly slow. On every page load, I had WordPress regenerate its rewrite_rules, depending on which HTTP_HOST is being accessed.
3) Change REQUEST_URI inside WordPress
Sounds scarier than it is. As soon as the request is inside WordPress—I chose wp-config.php, because it’s designed to be user editable—check which HTTP_HOST is being accessed, and then change the REQUEST_URI appropriately.
From there it’s just a matter of implementing a zillion WordPress hooks to change URLs whenever you output them, to remove the site prefixes. And to filter certain categories from blog listings, blog archives, et cetera. But I’ll save that for another post.