The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

how to swap addon domain with primary domain

Discussion in 'General Discussion' started by wintersun892, May 29, 2006.

  1. wintersun892

    wintersun892 Member

    Joined:
    May 9, 2006
    Messages:
    16
    Likes Received:
    0
    Trophy Points:
    1
    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
     
  2. Infopro

    Infopro cPanel Sr. Product Evangelist
    Staff Member

    Joined:
    May 20, 2003
    Messages:
    14,447
    Likes Received:
    195
    Trophy Points:
    63
    Location:
    Pennsylvania
    cPanel Access Level:
    Root Administrator
    Twitter:
    Setup a new account using the addon domain I think would be the least problematic.
     
  3. sparksupport

    sparksupport Member

    Joined:
    Apr 30, 2006
    Messages:
    20
    Likes Received:
    0
    Trophy Points:
    1
    Remove the present addon domain from his cpanel.

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

    SoftDux Well-Known Member

    Joined:
    May 27, 2006
    Messages:
    983
    Likes Received:
    0
    Trophy Points:
    16
    Location:
    Johannesburg, South Africa
    cPanel Access Level:
    Root Administrator
    But how would one do this is either the main domain, sub domain, or addon domain already contains data and user files? Removing the domain will remove the user's files (email, DB's, scripts, etc) as well, right?
     
  5. southnet

    southnet Member

    Joined:
    Oct 8, 2003
    Messages:
    10
    Likes Received:
    0
    Trophy Points:
    1
    Has this had a happy conclusion - I've had a similar request
     
  6. wintersun892

    wintersun892 Member

    Joined:
    May 9, 2006
    Messages:
    16
    Likes Received:
    0
    Trophy Points:
    1
    still not good conclusion yet
     
  7. pixelwerx

    pixelwerx Member

    Joined:
    Jan 16, 2006
    Messages:
    6
    Likes Received:
    0
    Trophy Points:
    1
    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.
     
  8. sneader

    sneader Well-Known Member

    Joined:
    Aug 21, 2003
    Messages:
    1,126
    Likes Received:
    21
    Trophy Points:
    38
    Location:
    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
     
    #8 sneader, Dec 26, 2007
    Last edited: Dec 26, 2007
  9. S-Combs

    S-Combs Well-Known Member

    Joined:
    Jun 10, 2004
    Messages:
    78
    Likes Received:
    0
    Trophy Points:
    6
    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.
     
  10. brianoz

    brianoz Well-Known Member

    Joined:
    Mar 13, 2004
    Messages:
    1,146
    Likes Received:
    6
    Trophy Points:
    38
    Location:
    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.
     
  11. Tam

    Tam Well-Known Member

    Joined:
    Jul 31, 2004
    Messages:
    103
    Likes Received:
    0
    Trophy Points:
    16
    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. address@addon.maindomain.com). 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.
     
    #11 Tam, Mar 22, 2008
    Last edited: Mar 22, 2008
  12. sneader

    sneader Well-Known Member

    Joined:
    Aug 21, 2003
    Messages:
    1,126
    Likes Received:
    21
    Trophy Points:
    38
    Location:
    La Crosse, WI
    cPanel Access Level:
    Root Administrator
    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
     
  13. brianoz

    brianoz Well-Known Member

    Joined:
    Mar 13, 2004
    Messages:
    1,146
    Likes Received:
    6
    Trophy Points:
    38
    Location:
    Melbourne, Australia
    cPanel Access Level:
    Root Administrator
    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 ...
     
  14. sneader

    sneader Well-Known Member

    Joined:
    Aug 21, 2003
    Messages:
    1,126
    Likes Received:
    21
    Trophy Points:
    38
    Location:
    La Crosse, WI
    cPanel Access Level:
    Root Administrator
    And THAT is nice to know... thanks for sharing !!

    - Scott
     
  15. danimal

    danimal Well-Known Member

    Joined:
    Jul 14, 2003
    Messages:
    79
    Likes Received:
    0
    Trophy Points:
    6
    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:
     
  16. theBassTender

    theBassTender Active Member

    Joined:
    Jan 2, 2005
    Messages:
    26
    Likes Received:
    1
    Trophy Points:
    3
    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?
     
  17. brianoz

    brianoz Well-Known Member

    Joined:
    Mar 13, 2004
    Messages:
    1,146
    Likes Received:
    6
    Trophy Points:
    38
    Location:
    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!
     
Loading...

Share This Page