Changing Primary Domain in Domain Access Settings

August 25, 2009
blog author



Changing the primary domain once it has been set in the Domain Access settings can be quite the challenge. I encountered a problem, which required me to change the primary domain to one of the active domains. This would have been easier if there were no nodes associated with the domains and if the project was in its early development stage. However, this wasn't the case. I had no choice but to write a script that would do a simple swap algorithm, which would switch the current primary domain's settings with the new primary domain (an active domain). Keep in mind that by the architectural design, the primary domain will always have an ID of “0”. The rest of the domains' ID will start with “1” and so on. For the purpose of this blog, let’s assume that the old primary domain is and the new primary domain is Here are the following steps I took in order to accomplish this task:

1) Switch the domain configurations of and To accomplish set some system variables for “domain_root,” “domain_sitename,” “theme_default, “site_frontpage,” “site_name,” “site_offline_message.” Then update the configuration of in the domain_conf table.

2) Swap the values of and in the domain table.

3) Swap the nodes associated with and in the domain_access table.

4) Swap the users associated with and in the domain_editor table.

5) Change the values of in the domain_theme table so that it reflects the values of