It’s a common task to have to replace (not upgrade) an existing site with a MODX site. Maybe you’re converting an Evolution site to Revolution, or converting a WordPress site to MODX Revolution. In any event, you don’t want the site to be down for days or weeks while you build the new site. What’s the best way to handle this?
There are actually a number of solutions to this problem. One solution is to build the new site in a subdirectory on the server. When it’s finished, you can either copy it to the root, leave it where it is and point the site to it in cPanel, or (if the original site was in a subdirectory) just rename the two subdirectories.
Another way to go is to build the new Revolution site on top of the existing site, by renaming files and directories. This always seems to confuse me, but it may work for you.
A third way is to create the new site on a localhost install and transfer it to the live server when finished. This can seem like an attractive alternative, but I’ve found it increasingly unsatisfactory. It often involves moving many files in both directions and configuring two different installs with totally different root paths. There are a lot of moving parts, and it’s easy for things to go very wrong. In addition, it’s difficult to implement this method without the old site being down for an indeterminate amount of time.
This method works really well for me. The old site is down for just a few seconds before the new site is up and it only takes a few seconds to revert to the old site if there are problems with the new one. It does require that all your sites be in subdirectories as recommended in the previous article.
In nutshell, you just create and work on the new site in a subdirectory. When it’s finished, you edit four files, rename the original subdirectory and the new one, and you’re done. See the previous article for more information on having a MODX site in a subdirectory.
I just did this recently for an Evo to Revo conversion. It worked really well and I didn’t even have to create a virtual host, although in my case, the client’s original site was in a subdirectory I’ll call
clientSite, reachable at
- Create a subdirectory called
clientSite2– it should be accessible with
- Copy the MODX files to the
clientSite2directory, or use one of the installer scripts mentioned on the Forums there.
- Put this in the browser’s address bar:
http://clientSite2.yourdomain.com/setup. (you may need to create the database first)
- If Setup goes well, let it delete the Setup directory
- Once MODX is installed, you should be able to log in by going to
Building the site
This part is all done the normal way. All your templates need this tag in the head section:
If, for some reason, that doesn’t work (internal links fail), use this one:
But remember to change it when you move the site.
All internal links on the site should be in the form of link tags:
[code]<a href="[[~12]]">Some Text</a>[/code]
The number in the link tag is the Resource ID of the resource it points to (visible in parentheses next to the page title in the Resource Tree at the left side of the Manager).
Putting It in Place
When the site is ready to replace the original, this is all you need to do:
- (optional) If you customized the base href tag, change the href to “[[++site_url]]”
- Log out of the dev. site
- Delete all files in the
- In cPanel’s file manager, edit the following four files. Change all instances of
clientSite.com(the address of the original site) — be sure you get them all in config.inc.php:
- Modify the
Rewrite Baseline if necessary
- Rename the
clientSite.old(site goes down at this point)
- Rename the
clientSite(site comes back up as the new site)
- Important: delete all files in the
- If you customized the base href tag in the template(s) and haven’t fixed it yet, you’ll need to change it now or internal links will not work
At this point, the newly developed site should be working fine at original address. If not, double-check the paths in the four config files you modified.
You can delete the old site (in the
clientSite.old directory) now, but I like to leave it there for a while to make sure everything is OK with the new site and to serve as a backup. I modify the
index.php files in the root and Manager folders by adding this at the top just below the starting php tag:
Don’t forget to remove that line if you end up having to restore the old site.