How to change domain extension without duplicating account

speedy200man

Member
Feb 20, 2017
9
1
3
Bucharest, Romania
cPanel Access Level
Root Administrator
Hello!

I am trying to change a domain name associated with an account and I am not sure what is the right procedure.
Right now, let's say we talk about domain.com that has a wordpress and some email accounts, totalling about 7 gb of data.
I want to change the main domain from domain.com to domain.net, without creating a new domain, duplicating data etc

After the change I would need to make redirects from the old website urls to the new ones, and create the new email addresses @ domain.net

Is this possible ? What is the best best way to acomplish this?

Thank you!
Cezar
 

lorio

Well-Known Member
Feb 25, 2004
313
20
168
cPanel Access Level
Root Administrator
After the change I would need to make redirects from the old website urls to the new ones, and create the new email addresses @ domain.net
Let's say you can change easily from .com to .net, how would you redirect? If com is removed from the account, you cannot redirect. The question is, what should happen to .com in the long run? If .com is not used on a different server or different context, you might just park .net on top of the .com account and do some redirecting. But it all depends on how the old domain will be used. If there is a complete separation, a different approach is needed.
 

speedy200man

Member
Feb 20, 2017
9
1
3
Bucharest, Romania
cPanel Access Level
Root Administrator
I managed to do it. These are the steps:
  1. Make a full backup
  2. Change the website URL in the database from .com to .net (for WP, you can find it in the _options table, usually first 2 records)
  3. Login to WHM - list accounts - modify account - change the domain.com to domain.net (the username needs to remain the same as the previous one, even if you are changing the domain name). Attention: this will automatically modify dns records and change email from @domain.com to @domain.net - i will fix this in the next steps.
  4. Add domain.com to add-on domains.
  5. Login to cpanel account - regenerate Auto-SSL.
  6. Go to domain redirects and create a permanent 301 redirect from the .com domain to the .net domain and check the wildcard redirect before hitting the Add button.
  7. Go to email Forwarders and Add Domain Forwarder from domain.com to domain.net - this will forward emails that come to the old domain.
  8. Login to the WP site, update permalinks and any hardcoded references to the old domain.
  9. Just to be sure, insert a .htaccess rule to permanently redirect old urls to the correspondent new urls.
Code:
<IfModule mod_rewrite.c>
  RewriteEngine On
  RewriteCond %{HTTP_HOST} ^domain.com$ [OR]
  RewriteCond %{HTTP_HOST} ^www.domain.com$
  RewriteRule (.*)$ https://www.domain.net/$1 [R=301,L]
</IfModule>
And you're done!
Cheers!
 

cPanelLauren

Product Owner
Staff member
Nov 14, 2017
13,296
1,261
313
Houston
I managed to do it. These are the steps:
  1. Make a full backup
  2. Change the website URL in the database from .com to .net (for WP, you can find it in the _options table, usually first 2 records)
  3. Login to WHM - list accounts - modify account - change the domain.com to domain.net (the username needs to remain the same as the previous one, even if you are changing the domain name). Attention: this will automatically modify dns records and change email from @domain.com to @domain.net - i will fix this in the next steps.
  4. Add domain.com to add-on domains.
  5. Login to cpanel account - regenerate Auto-SSL.
  6. Go to domain redirects and create a permanent 301 redirect from the .com domain to the .net domain and check the wildcard redirect before hitting the Add button.
  7. Go to email Forwarders and Add Domain Forwarder from domain.com to domain.net - this will forward emails that come to the old domain.
  8. Login to the WP site, update permalinks and any hardcoded references to the old domain.
  9. Just to be sure, insert a .htaccess rule to permanently redirect old urls to the correspondent new urls.
Code:
<IfModule mod_rewrite.c>
  RewriteEngine On
  RewriteCond %{HTTP_HOST} ^domain.com$ [OR]
  RewriteCond %{HTTP_HOST} ^www.domain.com$
  RewriteRule (.*)$ https://www.domain.net/$1 [R=301,L]
</IfModule>
And you're done!
Cheers!
This is exactly how you'd do this! Glad you were able to get it done, thanks for adding the steps that worked for you as well.