The Blog / Development / Manage Multiple Domains with MODx Revolution

Manage Multiple Domains with MODx Revolution

16 Jul 2010

With MODx Revolution 2.0.0 hitting RC3 it is not long before the final version is released. I took some interest in Revolution from the time it hit RC2 and have been working on a internal project with it. I wanted to manage a few internal websites with it so I put it to the test to see how easy it would be to do this.

I started off by reading this article on the MODx website and followed the steps in it to create another context to hold the site tree of the other website I wanted to manage. This all worked well and I had it up and running in no time, now it was time for me to have access to the manager from the subdomain website. There was no documentation on how to accomplish this on the MODx website or even from a google search. This started the challenge of how I would accomplish this, I created a manager directory inside of the subdomain directory and still it didn't work, I had to work this out myself and because I didn't want to start hacking MODx I reverted to using Apache's very own AliasMatch directive instead.

Here I will provide the code of what I did in order to get the manager and assets working with the subdomain. (Note: Both domains need to be on the same server)

  ServerName subdomainname
  ServerAdmin webmaster@localhost

  DocumentRoot /path/to/subdomain

  Alias /assets/ /path/to/install/assets/
  AliasMatch ^/connectors(.*) /path/to/modxinstall/connectors$1
  AliasMatch ^/manager(.*) /path/to/modxinstall/manager$1
  
  	Order allow,deny
	Allow from all
  

  # Possible values include: debug, info, notice,
  # warn, error, crit, alert, emerg.
  LogLevel warn
  ErrorLog /var/log/apache2/error.log
  CustomLog /var/log/apache2/access.log combined

I will explain what this bit of code is doing in relation to the subdomain.

AliasMatch ^/manager(.*) /path/to/modxinstall/manager$1

As you can see the AliasMatch directive is rewiting all requests for manager to the path where you installed modx and is substituting any request to manager to the appropriate file or directory in that directory.

AliasMatch ^/connectors(.*) /path/to/modxinstall/connectors$1

I did the same thing with the connectors directory as the manager requires this in order to run correctly. I also mapped my assets directory in order to keep them in one central location for all sites to access.

Social Media

Twitter
London Midland Train Train Power Plug Square Bob Sponge Pants at o2 Arena