Dynamic Board URL for MyBB – Run One Forum Under Multiple Domains

Many MyBB administrators make their forum available under more than one domain. Whether it’s for branding, easier access, or simply because multiple domains point to the same hosting account, this setup is quite common.

However, I recently ran into an issue where web fonts and other resources were still being loaded from the original domain, even though the forum was accessed through a completely different one.

After some investigation, I found that the culprit was MyBB’s bburl setting. Since many parts of MyBB (and some themes and plugins) rely on this value, they continue to generate absolute URLs based on the configured Board URL.

The Solution

Instead of using a fixed Board URL, we can override it dynamically at runtime based on the current hostname.

The following small plugin does exactly that.

Create a new file called:

inc/plugins/dynamic_bburl.php

and paste the following code into it:

Copy to Clipboard

Installation

Installing the plugin only takes a few seconds:

  • Upload dynamic_bburl.php to your inc/plugins/ directory.
  • Log into your MyBB Admin Control Panel.
  • Navigate to Configuration → Plugins.
  • Activate Dynamic Board URL.

From now on, MyBB will automatically use the domain that the visitor used to access the forum.

Benefits

This simple plugin offers several advantages:

  • Supports any number of domains pointing to the same MyBB installation.
  • No need to change the Board URL when adding a new domain.
  • Works with both HTTP and HTTPS.
  • Supports reverse proxies using X-Forwarded-Proto.
  • Compatible with installations located in subdirectories.
  • Prevents resources such as fonts, CSS files, and images from being loaded through the wrong domain.
  • This plugin only overrides MyBB’s bburl setting at runtime.