Multisite definition configuration
This page is about site definition configuration in the context of multisite. It explains how to configure multiple, distinct site definitions which require the definition of domains
and mappings
nodes.
For site rules configuration details, see Site resolution rules. |
We assume that you already know some basics about Magnolia site definition configuration (such as prototypes, themes, imaging variations and sitefn
templating functions).
Site app
Go to the Site app to configure a site definition.
If your bundle contains the Multisite module, the Site app shows the
node /modules/multisite/config/sites
from the configuration workspace.
When you open the Site app you see all configured sites as top-level nodes:
Node name | Value |
---|---|
|
|
|
In this example there are two sites: fallback
and comics-site
.
Site definition name
The node name of the site definition is called site-definition-name
.
If a site is properly configured, it can be accessed using the following URL:
<protocol>://<domain>:<port>/<context>/<site-definition-name>
This only works if the domain part of the URL is different from the domain that is mapped to the site of the given site-definition-name .
|
Mappings and domains
The mappings
and domains
nodes are required in a multisite context.
You must create a least one entry on both mappings and domains to ensure
a proper site definition for a distinct site.
Example:
sites: comics-site: mappings: website: URIPrefix: handlePrefix: /comics repository: website jolly-jumper: URIPrefix: /jollyjumper handlePrefix: /comics/belgian-comics/morris/lucky-luke/jolly-jumper repository: website domains: best-comics: name: www.best-comics.net
The site defined above allows you to access:
-
The content node
/comics
via the URL http://www.best-comics.net. -
The content node
/comics/belgian-comics/morris/lucky-luke/jolly-jumper
via the URL http://www.best-comics.net/jollyjumper.
Use different values for the site-definition-name
and the name of the
mapped node (handlePrefix
).
mappings
configuration
The mapping nodes define the JCR content nodes (usually page nodes) assigned to the site definition.
A mapping has the following properties:
Property | Description | ||
---|---|---|---|
|
required Each site can contain multiple mappings. The name of a mapping node is
arbitrary (in the example above, the node name is The corresponding class for a mapping is info.magnolia.cms.beans.config.URI2RepositoryMapping. |
||
|
required Name of the JCR workspace the mapping applies to. |
||
|
required The path in the workspace the content is served from. |
||
|
required Creates a node handle based on a URI. By default, a content request that
does not contain a prefix is served from the node defined on
The
Note that URIPrefix configuration can also be applied in modules independent from site definitions. Configuration in the site definition overrides the configuration in
|
domains
configuration
A domain node assigns a domain to the given site definition. It defines how the above mapped content node(s) can be accessed by URL. You can map multiples domain to the same site.
A domain mapping has the following properties:
Property | Description |
---|---|
|
required The name of a domain mapping node is arbitrary. You can apply multiple domain nodes per site. |
|
required Domain name such as http://www.best-comics.net. |
|
optional Port represents the port the web application was deployed on. Default is 80. |
|
optional HTTP or HTTPS. Default is HTTP. |
|
optional The context path of the Magnolia instance webapp such as
|
The optional properties port , protocol and context are only used
to build links between the pages of different sites. In a typical
production setup, where you serve the webapps from the root context on
different domains, you do not have to set port and context .
|
Extending site definitions
Another configuration strategy is to have one site definition for your
main
site with a
template prototype
that you can then reuse on other site definitions. This is a common
alternative to having multiple independent site definitions.
In the example below, site-2
and site-3
inherit from site-1
.
Node or property | Value |
---|---|
|
|
|
|
|
|
|
|
|
|
Inheriting mappings and domain can lead to unexpected
results and may destroy your site setup.
|
When extending site definitions, turn off inheritance for mapping
and
domains
by using @extends=override.
Node or property | Value |
---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Make sure you have no unwanted virtualURIMapping redirections on the public context. Use the Configuration app on the public context and search for On a standard Magnolia bundle, you most probably find the node /modules/ui-admincentral/virtualURIMapping/default which redirects to /.magnolia/admincentral You must delete the node to ensure a request to |