How to add custom URL in secondary Context?

Hi all,

I’m trying to assign a separate domain to a secondary context. Using dummy details for illustration, my context settings are:

base_url = /newsite/
http_host = newsite.com
site_start = 12345
site_url = https://www.newsite.com/newsite/

To remove /newsite/ from the visible URL, I added the following to .htaccess:

RewriteRule ^newsite/(.*)$ /$1? [R=301,L,QSD]

This gives me clean URLs, but the homepage then resolves to:

https://www.newsite.com/index/?cultureKey=newsite&q=index/

which makes me think MODX is falling back to its internal routing because the context still expects base_url = /newsite/.

If I remove /newsite/ from base_url and site_url entirely, the request falls back to the default web context and homepage.

Has anyone successfully configured a secondary context to run from its own domain without requiring the context prefix in the URL? Is there a recommended way to handle domain-based context routing in this scenario?

Any pointers would be much appreciated. (Am using MODx 2.8.6)

MODX has no “internal routing”. By default it always just loads the “web” context.


If you have two different domains for your contexts, you can use a routing extra that can handle domains/subdomains. For example SmartRouting should work:

Or you could also write a simple custom routing plugin yourself.


When the context is determined by the domains, there is no need to use a base_url that differs from the default (/).

There is also no need to change anything in the .htaccess file (like extracting the “cultureKey” from the request).

What do you mean by “run from its own domain”? What are the exact URLs you want for the main and secondary domains?