Skip to content
Johan Janssens edited this page Jun 11, 2019 · 26 revisions

Joomlatools Pages has build in multi-site support. A default installation of pages will use the root /joomlatools-pages folder, with multi-site is enabled it becomes possible to re-configure this default folder and add additional sites.

1. Configure default

To re-configure the default site you need to add a configuration-pages.php to your Joomla root, or in case of Joomlatools Platform to /config directory. The configuration will re-define the location of your site:

<?php
return array(
    'sites' => [
        '[*]' => JPATH_ROOT.'/sites/mysite.com',
    ],
);

The default value for the sites config option is [*] => JPATH_ROOT.'/joomlatools-pages'

2. Adding sites

To add additional sites a route for each site need to be added that resolves the URL to a directory on the file system.

For example to add an example.com and a intranet.example.com site you can use the following routes:

<?php
return array(
    'sites' => [ 
        '[www.]?exmample.com/shop[*]' => JPATH_ROOT.'/sites/shop'
        '[www.]?example.com[*]'       => JPATH_ROOT.'/sites/site',
        'intranet.exmample.com[*]'    => JPATH_ROOT.'/sites/intranet'
    ],
);

Rules

  • Routes are resolved in FIFO order. The first defined route is resolved first, if it cannot be resolved the next route is used, and so on.
  • Routes are resolved against the HOST + PATH information of the URL. The url schema eg, http:// or https:// should be omitted from the route, otherwise it will not resolve.

Wildcards

  • [*] will match up to the next trailing slash, it ensure that both example.com, example.com/ and example.com/path are matched.
  • [www]? ensures that both www.example.com and example.com are matched.

See also: URLs and Linking > Routes > Match types

Note: You can add additional global configuration options to configuration-pages.php. You can still override the options per site in the sites config.php

3. Routing sites

Instead of defining a single route per site, it's possible define a route that can route multiple domains. For example to dynamically route all subdomains you can use the following route:

<?php
return array(
    'sites' => [
        '[alpha:site].example.com[*]'   => JPATH_ROOT.'/sites/[:site]',
    ],
);

Wildcards

  • [alpha:site] is a named wildcard that matches the domain. It will only match alphabetic subdomains, and it will not match example.com
Clone this wiki locally