how to swap addon domain with primary domain

wintersun892

Member
May 9, 2006
16
0
151
I have a client want to change his primary domain to addon domain and vice versa. What is the best way to do that.
Thanks
 

sparksupport

Member
Apr 30, 2006
20
0
151
Remove the present addon domain from his cpanel.

Now in WHM modify accounts section change the primary domain name to that of addon domain.
 

pixelwerx

Member
Jan 16, 2006
6
0
151
Remove the present addon domain from his cpanel.

Now in WHM modify accounts section change the primary domain name to that of addon domain.
This worked flawlessly for me. I had an identical situation with a hosted client whose domain changed as the result of a trade name dispute.
 

sneader

Well-Known Member
Aug 21, 2003
1,195
68
178
La Crosse, WI
cPanel Access Level
Root Administrator
Worked for me, after httpd restart

For an Add-on domain, I would think you'd also have to move all the files from the subdirectory that the Add-on domain used to point to, into the main public_html folder. That may be obvious, but thought it was worth mentioning.

- Scott
 
Last edited:

S-Combs

Well-Known Member
Jun 10, 2004
78
0
156
I just had a similar request from a client who wanted a 'Parked' domain to replace their primary domain.

The method posted above by sparksupport worked fine for this transition also but I also had to edit their .htaccess file because, it left the old redirect information intact throwing a 500 error.
 

brianoz

Well-Known Member
Mar 13, 2004
1,146
7
168
Melbourne, Australia
cPanel Access Level
Root Administrator
With the method recommended above ("delete the addon and rename the primary") the problem is that you may lose all the stuff associated with the addon when you remove it.

Has anyone tested whether associated email accounts actually do get lost?

If so, I'm pretty sure restoring the home directory accounts after the change will restore the mail accounts, I think we have tested this although as it was done by one of my team I don't recall details.

If cpanel doesn't delete the email accounts when the addon is removed, the whole problem goes away as it's simply a matter of removing the addon/parked domain and renaming the primary, then adding back the other domain.
 

Tam

Well-Known Member
Jul 31, 2004
112
10
168
We often have to move an addon domain to a new account, but have not changed one to a main domain in the manner you indicate, although the method we use would work just as well with the only exception of email accounts which would have to be recreated because of the mail address on the subdomain component (i.e. [email protected]). We offer to recreate the email accounts for the client if they wish us to, but that of-course involves letting us know the password(s) required as well as the email address(es).

First we create a temporary folder outside of their web space and move all files from the addon domain's folder to that temproary directory.

Then we delete the addon domain (from within their cPanel to ensure it is deleted properly).

Then we create the desired account for the old addon domain and move the files and folders from the temporary folder to the new account's public_html folder (in your case we wouldn't want to change the main domain on the existing account because we want to move the addon domain's files and folders into the web root on that account and preserve the old main domain's files and folders).

We then chown -R the public_html folder to the new username. That complete's the creation of the new account with the addon domain now becoming the main domain for that account.

Your next step would be to move all of the files and folders in the public_html folder of the old account (the main domain for the old account) into a temporary folder and then delete that account. Create an addon in the new account and move the files and folders from the temprary folder to the new addon domain folder and recursively chown (as before). But you will have to recreate, or ask the client to recreate all email addresses for both domains.

Once you've chowned, you will have to reinstall Frontpage extensions if they were in use, and sometimes we see a 500 Internal Server error which is cured by 'chmod 0755 /home/username/www' (replace username with the acutal username of-course).

It looks like a lengthy process, but with something like WinSCP, its actually prettty quick and easy to do.
 
Last edited:

sneader

Well-Known Member
Aug 21, 2003
1,195
68
178
La Crosse, WI
cPanel Access Level
Root Administrator
With the method recommended above ("delete the addon and rename the primary") the problem is that you may lose all the stuff associated with the addon when you remove it.

Has anyone tested whether associated email accounts actually do get lost?
Yep, I have done a lot of these lately, and it really works! I don't know WHY, but cPanel does NOT delete the mail accounts associated with the add-on domain, when you delete it. So, it's really easy to delete the Add-on domain... use Modify Account to change the primary domain for the account, to the former Add-on domain name.... and it works!

- Scott
 

brianoz

Well-Known Member
Mar 13, 2004
1,146
7
168
Melbourne, Australia
cPanel Access Level
Root Administrator
I don't know WHY, but cPanel does NOT delete the mail accounts associated with the add-on domain, when you delete it.
Ah ... that's so nice to know! I just tested and while it KEEPS the mail accounts (mail/domain.com/account/* and etc/domain.com) it DELETED the forwarders file (/etc/valiases/domain.com).

Not hard to restore the forwarders though, once you're expecting this to happen. Pity it doesn't have a "keep forwarders" button. This could be implemented by copying the forwarders file to the mail/domain.com directory then checking for it on creation of a parked or addon domain.

Not sure if there's any way to code this yourself ...
 

danimal

Well-Known Member
Jul 14, 2003
79
0
156
Add-on Software & DBs?

How does this handle fantastico-installed software? I am in this situation but the add-on domain has a word-press install on it.

-Danimal :cool:
 

theBassTender

Active Member
Jan 2, 2005
26
1
153
similar situation

I have a client wanting to delete his primary domain altogether and retain his parked domain. They have email accounts on the parked domain they wish to retain.

In this case, would I only need to modify account ---> change the main domain to the parked domain? Would I then need to delete the parked domain or would it matter?? Has anyone run across this situation?
 

brianoz

Well-Known Member
Mar 13, 2004
1,146
7
168
Melbourne, Australia
cPanel Access Level
Root Administrator
You'd need to delete the parked domain first, but you then should be able to use modify account to change the primary domain. I'm fairly sure the email accounts will keep running across this but obviously test it straight after doing the above.

I'd make and set aside a full backup of the account first, just in case, it's just common sense and will allow you to recover if things go horribly wrong!
 

eugenevdm.host

Well-Known Member
Oct 21, 2019
90
14
8
Cape Town
cPanel Access Level
DataCenter Provider
Hi guys / @cPanelLauren,

Please correct me if I'm wrong:

To convert from an add-on domain, to a root account, is easy:

1. Use WHM interface.
2. Navigate to Convert Addon Domain to Account
or use command line `whmapi1 convert_addon_initiate_conversion domain=example.com user=example`

To convert from root account to add-on domain, is impossible without a lot of manual work:

1. No WHM interface.
2. Cannot use full backup
3. Need to manually backup files and database and restore.

I found a list of references for doing it in the one direction.

We need to understand why we can't do it in the other direction? Is there an architectural reason for this?

The two references that refer to the one direction do not mention the other direction. Is this definitely not possible?

References:
https://docs.cpanel.net/knowledge-base/accounts/addon-domain-conversion-list/
https://docs.cpanel.net/whm/transfers/convert-addon-domain-to-account/82/

Thanks.
 

cPanelLauren

Product Owner II
Staff member
Nov 14, 2017
13,266
1,304
363
Houston
Hello,


There is a process for converting an addon domain to an account but there does remain no method of natively converting an account to an addon domain. I do believe there is a feature request for this still open as well here: https://features.cpanel.net/topic/convert-cpanel-account-to-addon-domain

This does take manual work, but there's no reason why you can't use a cPanel backup from the original account, you'd have to modify the ownership of the files within but you'd need to do this if you were doing it manually as well.