Hosting Multiple Websites with ModX Revolution

Hosting Multiple Websites with ModX Revolution

Hosting Multiple Websites with ModX Revolution

This is a neat and tidy way to have multiple TLDs for one installation of MODx.

Within MODx

Go to System > Contexts and Create New for each domain. Name each one using camelCase (e.g. websiteOne) as you can’t use spaces here. This name will be seen in the site tree within the Manager and you will also refer to it later on.

Once finished refresh the manager and they will appear down the left. Right click each one and then Quick Create > Document Here to make a home page. Add a small piece of text on each of the pages so when you test you know it’s reaching the right destination.

Now add content settings by clicking on each heading and add the following:

site_start – the ID of your new context’s homepage.
base_url – Set this value to / as we’re making the root of the URL our base.
http_host – Set this value to
site_url – Set this value to (Full domain url with a  trailing slash)
error_page – Error page to be set to the id of the context’s home page for now

You can add more here for further customisation. You can create any new ones you like.

File Structure

At the root of the web directory add a directory for each domain and copy index.php and config.core.php from root into each one. There are 2 changes you need to do here (in each directory):

  1. In index.php change $modx->initialize(‘home’); to $modx->initialize(‘websiteOne’);
  2. In config.core.php change define(‘MODX_CORE_PATH’, dirname(__FILE__) . ‘/core/’); to  define(‘MODX_CORE_PATH’, ‘/server/path/to/core/’);


Now you need to tell the server to use these sub directories when each domain name is used. To do create an htaccess file with the following information (update domains and folder names to suit):

RewriteEngine On

RewriteCond %{HTTP_HOST} ^
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule (.*) folderone/index.php?q=$1 [L,QSA]
RewriteCond %{HTTP_HOST} ^(www.)?$
RewriteRule ^(/)?$ folderone/ [L]

RewriteCond %{HTTP_HOST} ^
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule (.*) foldertwo/index.php?q=$1 [L,QSA]
RewriteCond %{HTTP_HOST} ^(www.)?$
RewriteRule ^(/)?$ foldertwo/ [L]

php_value memory_limit 64M



Let Us Help

Get You Online

Contact Us Today

Important Cookie Information
Our website uses cookies. By continuing to browse the site you are agreeing to our use of cookies. For more details about cookies and their use, please see our Cookie Policy.