Important This is work in progress and FAR away from completed.
I want to have two contexts:
- Homepage: resources handling actual content
- Static: resources handling static content like css, js, layout images.
- Create a subdomain and point it to the directory of the parent domain.
- Create the followg resources inside your new contexts (see screenshot below)
- Create a new context and add the following settings
key | value |
---|---|
base_url | / |
error_page | 13 |
http_host | static.relaunch.example.com |
site_name | Static Files |
site_start | 10 |
site_status | No |
site_url | https://static.example.com/ |
site_unavailable_page | 14 |
- At this point you should see your maintenance pageIf you open
If you want to redirect a request to a specific context, you need a plugin that triggers on OnHandleRequest.
You have several options:
- Write your own router.
- Install a plugin that does the job:
- XRouting - Does Domains, Subdomains and Folder
- ContextRouter - Outdated, use XRoutung instead
- Gateway Manager - Comes with an interface that helps you to setup mandatory context settings
If you set the site_status of a context to 0 (maintenance mode), you can only see it if you have logged into this context.
This means, that if you logged into the main domain manager at example.com, you can see all pages related to this context (usually web) even if your site_status is 0. If your site_status is 1, you can still also see unpublished resources.
If you try to see an unpublished page from another context, or if your whole context is under maintenance, then you see your maintenance page instead. If your site_status is 1, you can still not see unpublished resources.
One way to solve this is ito log into the other contexts as well (static.example.com/manager).
There should be a simpler solution, but I haven't found it sofar.
If a context doesn't need any personalization, you may want to set this contexts session_enabled to 0.
Important Don't add this settiing directly to your system settings, as this will prevent you from accessig the manager. Always add this setting to a contexts settings.
Read more: https://modx.com/blog/new-for-2.2.1-session-less-contexts
This should help, but it doesn't: https://docs.modx.com/current/en/building-sites/settings/session_cookie_domain