b2evolution b2evolution

  • Sign in
  • Sign up
  • About
  • Downloads
  • Hosting
  • Docs
  • Support
  • Sign in
  • Sign up
  • Manuals Home
  • Latest Updates
 
  1. b2evolution CMS User Manual
  2. Installation / Upgrade
  3. Advanced Setup
  4. Multi-Domain Setup
  5. Using Multiple Domains

Using Multiple Domains

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.

1. Prerequisites

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 same public_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:

<VirtualHost *>
        ServerName maindomain.com
        ServerAlias *maindomain.com
        ServerAlias *anotherdomain.com
        ServerAlias *yetanotherdomain.com
        UseCanonicalName Off
        DocumentRoot /home/myfolder/public_html
        DirectoryIndex index.php
</VirtualHost>

On a local machine

Please see the page: Setting up a multidomain test environment.

3. Configuring your collections

It is now time to let b2evolution recognize each domain & sub-domaing that is pointing at index.php and display a different collection/blog for each.

To achieve that, go to Collection Settings > URLs for each of the collections you want to display on a specific domain:

Using Multiple Domains

Here you can set the "Collection Base URL" as either a sub-domain of your main domain or even a completely different domain by selecting "Absolute URL".

Enter the full URL of your special domain in the Absolute URL field, for example: http://www.anotherdomain.com/ (IMPORTANT: Don’t forget the trailing slash or you will get an error!)

Once you save the changes, calling up http://www.anotherdomain.com/ in your web browser should now show the collection/blog associated to that domain.

4. Configuring hidden URLs

Your b2evolution collections will load additional resources from the server through the skins, /rsc/, /plugins/ and /media/ directories.

If you are using different domains, you may or may not want to access these resources through your main domain ($baseurl).

You can control this through these settings: Assets URLs / CDN Support Panel.


5. Dealing with cookies / logging in [OLD]

In many cases this is now completly automated in b2evolution 6.7.5+.

For more information, see: Logging-in on multiple domains

6. htsrv URL [OLD]

Ignore this section if you are using b2evolution 6.7+.

The $htsrv_URL is used:

  • for posting comments and you may find it cleaner to have b2evolution
  • for callbacks by some plugins (e.g. the Captcha Image)
  • for AJAX callbacks. In this case it is especially important that the callback goes to the same domain and uses the same protocol (http/https) as the containing page.
  • for generating on-demand image thumbnails.

In older versions of b2evolution, your needed to dynamically create the $htsrv_URL variable in _advanced.php, e.g.:

$htsrv_url = 
    ( (isset($_SERVER['HTTPS']) && ( $_SERVER['HTTPS'] != 'off' ) ) ?'https://':'http://')
    .$_SERVER['HTTP_HOST'].'/htsrv/';

7. Redirects between domains [OLD]

Ignore this section if you are using b2evolution 6.7+.

In older versions of b2evolution, if you wanted to redirect between your domains, you needed to set following in your _advanced.php:

$allow_redirects_to_different_domain = 'always';

Tags: 6.7.5
Created by fplanque • Last edit by fplanque on 2016-08-06 18:19 • •

10 comments

Comment from: smyt

Lance McCollum

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.

2013-09-13 @ 22:50

Comment from: fplanque

@smyt : any information about configuring NginX would be welcome. Thanks for your help.

2013-10-03 @ 00:05

Comment from: drherz

I am using GreenGeeks, which I actually got from your suggestions. Thanks, by the way. I like them.

As to this portion of the manual, you might also want to add that to choose a default blog to show up without any extra text, one has to go to

Dashboard > Blogs > (All>)Settings and set the default blog.

I put the all in parentheses as it does not appear in the "• You are here:" line on the dashboard pages.

2013-10-06 @ 07:06

Comment from: drherz

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?

2013-10-06 @ 07:40

Comment from: mgsolipa

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.

Here you will find additional information to get you some context: http://stackoverflow.com/questions/1100343/apache-redirect-from-non-www-to-www, http://forums.cpanel.net/f5/canonical-redirect-www-non-www-same-domain-228492.html, http://authoritylabs.com/blog/solving-canonical-problems/

2013-10-06 @ 11:19

Comment from: csaba

csaba

Hello,
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!

2017-07-20 @ 20:59

Comment from: csaba

csaba

CORRECTION: it must NOT be redirected at all, the root directory of the sub-domain has to be the same as the b2evolution install directory..

2017-07-20 @ 21:04

Comment from: csaba

csaba

I ‘ve just tried with a real domain, too.
So, the was is the same with sub or main domain.
NO REDIRECTION! The document root folder has to be the same as the b2evolution install root folder!

2017-07-20 @ 21:07

Comment from: thatgrrl

Laura Brown

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.

2017-12-13 @ 23:42

Comment from: theking

Panthera Leo

In case someone comes looking for the "Setting up a multidomain test environment":

I sucessfully managed to have multiple different subdomains at localhost to simulate the multi-domain strategy. As I use XAMP for Windows, I had to edit 2 things:

  • C:\Windows\System32\drivers\etc\hosts
  • C:\xampp\apache\conf\extra\httpd-vhosts.conf

More info can be found at:
https://b2evolution.net/man/multi-domain-test-environment
http://www.pauloacosta.com/2016/07/criando-multiplos-virtual-hosts-no-xampp

2019-03-31 @ 23:13

On this page

  • 1. Prerequisites
  • Use the correct b2evolution files
  • Start with a working single domain
  • Understand the principle of a multi-domain setup
  • 2. Configuring your web server for multiple domains
  • On shared hosting & cPanel hosting
  • On VPS / Dedicated / Linux command line hosting
  • On a local machine
  • 3. Configuring your collections
  • 4. Configuring hidden URLs
  • 5. Dealing with cookies / logging in [OLD]
  • 6. htsrv URL [OLD]
  • 7. Redirects between domains [OLD]

Search the Manual

Content Hierarchy

  • b2evolution CMS User Manual
  • User's Guide
  • Installation / Upgrade
    • New Installation
    • Upgrade
    • Configuration files
    • Advanced Setup
      • Test features
      • Intranet installation
      • Intranet setup
      • After Installation / Upgrade
      • Setting up the Scheduler
      • Multi-Domain Setup
        • Using Multiple Domains
        • Setting up a multidomain test environment
        • Logging-in on multiple domains
      • Multiple instances
      • File Permissions
      • How to change the location of admin.php
      • Google API key
      • GitHub API key
    • Migrating from Another System
    • Moving your b2evolution Site
    • FAQ & Troubleshooting (Installation / Upgrade)
    • Assumed User Skills
  • Front-office Reference
  • Back-office Reference
  • Developer Reference
  • Operations Reference
  • Advanced Topics
  • Glossary
  • Archives
Bootstrap CMS

This online manual is powered by b2evolution CMS – A complete engine for your website.

About b2evolution

  • What is it?
  • Features
  • Getting Started
  • Screenshots
  • Online demo
  • Testimonials
  • Design philosophy
  • Free & open source
  • Terms of service

Downloads

  • Latest releases
  • Skins
  • Plugins
  • Language packs

About us

  • About us
  • Contact

Webhosting Guide

  • Web hosting blog
  • Best web hosting
  • Cheap web hosting
  • Green web hosting
  • Hosting with SSH
  • VPS hosting
  • Dedicated servers
  • Reseller hosting
  • Int'l: UK / France

Docs & Support

  • Online manual
  • Forums
  • Hire a pro !

Other

  • Adsense
  • Press room
  • Privacy policy

Stay in touch

  • GitHub
  • Twitter
  • Facebook
  • LinkedIn
  • News blog
  • RSS feed
  • Atom feed

Founded & Maintained by François Planque