b2evolution can run multiple blogs/collections on multiple domains in almost any imaginable configuration (domains, sub-domains, sub-folders…), all this on a single b2evolution installation.
In a nutshell, to display your b2evolution collections on multiple domains, all you need to do is point all your domains at index.php and let b2evolution recognize the requested URL to display the matching blog/collection.
Note: If you want to be able to log in on multiple domains, you should really pay attention to what you are doing. Make sure you read through this entire page.
If needed, we provide a step by step procedure below that may help if you’re new to configuring multiple domains on your web server.
It is extremely important you understand this before jumping to step 2.
Use the correct b2evolution files
For the following to work:
You MUST use b2evolution version 6.6+
If you want to log in on multiple domains, you MUST use b2evolution version 6.7.5+
You MUST use the .htaccess file provided by b2evolution in your base folder. If in doubt, rename the sample.htaccess file provided by b2evolution to .htaccess.
You MUST use the index.php file provided by b2evolution in your base folder.
Again: this will not work if you don’t use the correct .htaccess and index.php files.
Start with a working single domain
Before attempting to set up multiple domains, you should already have one domain set up and working correctly.
We will assume you have the following working:
You have the domain www.maindomain.com correctly set up and pointing to the public_html folder on your server. (Note: Your web content is served out of a directory of the server. That directory is typically called public_html. In some situations is may also be called www. In many cases,www is just an alias name for public_html.)
You have b2evolution installed in public_html and b2evolution’s main index.php file located at ]public_html/index.php.
In this configuration, calling up http://www.maindomain.com/ in your web browser, will invoke public_html/index.php which will, in turn, fire up b2evolution and b2evolution will display its default Collection/Blog here.
Understand the principle of a multi-domain setup
The principle is that you will set up ALIAS domains that all open the exact same public_html/index.php file on your server. So, at first, they will all display the exact same b2evolution page as the main domain. Then, in step 3, we will show you how to make b2evolution automatically recognize the domain to display a custom collection/blog for each.
So, as a first step, you want to obtain this:
Calling http://www.maindomain.com/ in your browser, should display your default collection/blog.
Calling http://www.anotherdomain.com/ in your browser, should display your default collection/blog.
Calling http://www.yetanotherdomain.com/ in your browser, should display your default collection/blog.
And the same would be true if you were trying to set up subdomains:
Calling http://www.sub1.maindomain.com/ in your browser, should display your default collection/blog.
Calling http://www.sub2.maindomain.com/ in your browser, should display your default collection/blog.
Calling http://www.sub.anotherdomain.com/ in your browser, should display your default collection/blog.
You may need to ask your web host for support in this step.
2. Configuring your web server for multiple domains
On shared hosting & cPanel hosting
If you are using shared hosting, or any type of hosting that involves a control panel like cPanel:
Check that your hosting plan allows multiple domains ;
Set your additional domains up as "Domain Aliases" (this is the easiest to use in cPanel).
If you are tempted to use the "Subdomain" option in cPanel, be very careful to erase the sub-folder name that cPanel will automatically suggest for you when you add you sub-domain. Make sure your sub-domain uses the same webroot folder as your main domain.
Do NOT set up your additional & sub domains as sub-folders of your main domain. Remember that you want all your domains to open up the samepublic_html/index.php file at the root of your website.
Pro tip: some web hosts will let you add a wildcard subdomain in cPanel (e-g: *.maindomain.com) pointing to your public_html directory. By using this, you may use as many subdomains as you want, without configuring them one by one in cPanel.
Remember that in all cases if you change the DNS configuration of your domain there can be a propagation delay that may last up to 48 hours before your domain actually points to the correct web server.
On VPS / Dedicated / Linux command line hosting
If your are using a VPS or a dedicated server which can be configured through the command line and configuration files, make sure to set up your webserver so that all (sub-)domains map to the same DocumentRoot (as it is called in Apache).
In order to replicate the layout described in Step 1 with the Apache web server, your apache2.conf file should include something like this:
Don't forget, more and more sites are running under nginx. That is my case and I will have to work some of this out with my host. This will be easy, because of the close relationship I have with my host and their desire to host many, many b2evolution sites/subdomains. Thanks.
I notice on using the absolute URL that one is forced to choose either http://www.sub.domain.com/ or http://sub.domain.com/, and that my browser (Opera v. 16.0.1196.80) at least will not automatically call one if the other is called. Is there a way to make sure that either variation of the name will land a person on the intended blog?
Hello @drherz, the problem that you mentioned is known as canonical redirect. Basically you need that the request done over www.sub.domain.com goes to sub.domain.com (this is the URL that you should set at your b2evolution).
As always, there are a couple of ways to achieve this, now a "redirect" based on the Apache's Rewrite could help you, but be careful because this adds extra load to your apache. Again, your provider is the best on guiding you across this kind of things.
It didn’t work for me.
I changed the recommended settings in the following way:
the additional sub-domain has to be NOT an alias, but a real sub-domain!
It has to be redirected NOT to the index.php file but only to the root folder!
I haven’t tried with real domain name, only sub-domain but it was the sub-domain of the domain which was the b2evolution installed to!
I needed help from my web host, Hosting Matters, to figure out the alias part. But, as far as making it work on b2, I was surprised how simple it is. Basically, just add a new collection and change the setting to the parked/ alias domain. Now I’m adding the content from what were WordPress sites. I will be so happy to have them all in one.
Thank you for the multi domain set up and the WordPress migration feature too.