MODX Community

Manage multiple sites with MODX

I am setting up a multi-site MODX installation. Does anyone have a tutorial on how to get multi-sites to work in MODX including if there are any DNS changes that need to be made for the domain(s)?

I never tried this, but I believe it is possible to use it with Xrouting extra and use the multi-context approach.
You should point your domains / sub domains to the same up of your modx server instance and XRouting should do the job of the contexts are properly configured.
I will let other experienced users to comment on this.

I believe this is what I used to get my multi-site instance set up: I couldn’t find any new tutorials in the docs. :slightly_frowning_face:

No extras/mods required.

As long as your DNS records are directing your domains to your host, I don’t think you will have to modify them. Then, based on where the actual sites will live, you will need to point your domains appropriately via your host…it worked way better than I thought it would.

I did run into a snag…But all is working now. :grimacing:

Thanks for the replies!

What I have done so far is create a context for my 2nd domain with settings for http_host, site_url, setting_site_start, and email sender. I think installed XRouting

Using an A Record, I pointed my 2nd domain to the same IP as my main IP. But it isn’t working. I am not sure what I am missing.

XRouting is great for multilingual websites but I’ve had issues using it with multiple domains before. The easiest way to do this is using your own context switcher plugin:

So, create a new plugin and copy and paste the code below into the Create/edit plugin tab (Update the domain name and context keys):

/* don't execute if in the Manager */
if ($modx->context->get('key') == 'mgr') {

switch ($_SERVER['HTTP_HOST']) {
        case 'domain1.tld':
                // if the http_host is of a specific domain, switch the context
                $modx->switchContext('web'); // Context key
        case 'domain2.tld':
                // if the http_host is of a specific domain, switch the context
                $modx->switchContext('domain2.tld'); // Context key
                // by default, don't do anything

Then click the System events tab at the top of the plugin page and in the list search for OnHandleRequest. Check the Enabled box.

That should work, but you’ll probably need to update your htaccess/ nginx config to handle the multiple domains and friendly urls.

1 Like

Thanks inside-creative! I have applied your plugin and customized the URL and keys but it still doesn’t seem to work. My secondary domain is pointed to the same IP as the main domain with an A record.

Perhaps I need to make changes to htaccess / nginx as you mentioned. Sorry for being a nube at this, but can you give me an idea of what changes would be made to the htaccess / nginx?

No worries, we were all new once :D.

What server are you running? Are you running an Apache server or Nignx? Or are you using ModxCloud hosting or another host? (need to determine what we need to update).


  • Do you get any errors in your error log when you visit the second domain?
  • What error page do you see when you visit the second domain? Is it a 404, 403, 501…

I am on an Apache server. It isn’t in ModxCloud (just another hosting provider). I am not getting any error message in the MODX log when I try to view the second domain. When I try to go to the second domain, I am getting the hosting provider’s ‘parked’ page.

That sounds like you still need to point the domain to go the same MODX installation, on the hosting side. How that works exactly depends on the host, but typically you’d add a “Domain Alias” or “Pointer Domain” or something like that.

What hosting are you using? As @markh mentioned you need to point the domain to the Modx installation. I know on hosting like 1and1 you can point the domain to a sub directory on your web server, just Double check the path

Thanks markh and inside-creative! It turns out it was a setting with the hosting provider. My hosting provider doesn’t have Domain Aliases as a feature, but does allow for “Addon Domain” in the hosting settings for the main domain. I just need them to enable that feature as it is now allowed by default.

To summarize how I ended up having it work:

  • I created the context and settings
  • I installed the Gateway Manager plugin and setup it up with my settings.
  • Setup the Addon Domain feature to add the secondary domain to the main domain