migrating subdomain to new web host

Migrating a subdomain to a new server [13]

Moving to a new web server

Maybe I have been living this situation. I have learned from it. Sharing this information as there was no complete resource to explain that.

Situation

You have a main domain and a number of subdomains.

Domain:

supermain.com

Subdomain:

more.supermain.com

less.supermain.com

inbetween.supermain.com

A new webhosting provider came with unbeatable prices. Or is it your old webhost who has a crappy service ?

Whatever the reason for a move, this can be a daunting task. Well, not everytime, if you understand what is happening, it can be easier !

This article applies mainly to Shared Webhosting providers. The same logic could apply to VPS and Dedicated servers.

Shared Webhosting Providers

Companies go for shared webhosting providers saying implementation is easier. Within a matter of clicks, you can get everything up and running. From my point of view, this may be true to a certain degree.

The huge issue with shared webhosts is the lack of visibility. And this is done on purpose. As a person who worked mainly on Dedicated and VPS, this was hell. Everything is already set-up in a crappy way. The logs are limited or non-existant.

The process of Migrating a Subdomain

You need a plan. First of all, you have to assess the number of subdomains you have. The applications that are running on the subdomains etc..

  1. Migrate one subdomain
  2. Make sure everything is working correctly.
  3. Go ahead and migrate all subdomains.

1. Moving your Data

The most widely used CMS are easy to migrate. (drupal, wordpress, etc…)

  1. First you move all your files from hostA to hostB
  2. You proceed with making a dump of your Database and migrate it.
  3. You test your application thoroughly.

2. Subdomain migration

Your files are already on your new webhost. But your subdomain more.supermain.com is still on your old webhost.

You need to point the domain to the IP of the new host.

migrating a subdomain to a new host

  1. Assuming you are keeping your DNSs at your old host. Go to the CPANEL of your OLD host
  2. Go to the Domains section
  3. If you are using the advanced zone editor, you need to locate your subdomain records. Say it is a CNAME that is pointing to a certain name.
  4. You need to delete the old CNAME, after making a backup of course.
  5. Then, you create an A record that needs to be pointed to our new webhost, say 23.22.22.23.
  6. Now, the DNS records say clearly that your subdomain has moved.
  7. We can proceed to our new webhost.
  8. On your new webhost, you need to create a subdomain, assuming that your main domain is the same as what you had before.
  9. Create a subdomain by typing it’s name : more (as in our example( and selecting your main domain.
  10. Your webhost will then ask you to point your subdomain to the ‘document root’. This is where your application and files reside. One DocumentRoot = 1 application.
  11. You may have to wait a little before DNS propagation.
  12. DNS propagation can be checked on this site: dnschecker
  13. We want to type in the subdomain name and check the A record.
  14. It should point to the IP of our new webhost.

3. Mails not working nightmare

Your application is working perfectly? Almost. Mails are not working. This can become a real deal-breaker if you don’t understand what is happening.

Symptoms

  1. You are  able to send mail from subdomain to the domain.
  2. But you never receive that mail in your domain mailbox !
  3. We are able to send mails to third party mail providers: gmail, yahoo, live, etc..

Causes

There can be a number of causes for that. But if your web application is not giving any error logs (saying that mails are being sent properly). Forget about your webhost’s logs, they most probably don’t have any !

Tried everything still not working

In that case, that solution may work for you. It may be because our subdomain uses the name of the main domain. When you are trying to send a mail your webhost is ‘intelligently’ routing the mail internally to skip the overhead of the ‘internet’.

There are 2 configurations that must be done from your webhost. You can do it via cpanel of our NEW host!

  1. Email Routing – Look for that option on your cpanel. Look for your domain name. You will see 3 options: Local, Remote and Backup. We want to choose Remote, and let our main host continue to deal with emails.
  2. DNS – Having set our email server to remote, we need to tell our webhost where to route the mails. We need to locate any existing MX(Mail exchanger) records. Once located, we remove it (make a backup before or a mind map if your memory is good!). We then add exactly the same MX as your main domain.
  3. SPF (optional)- Your MX might not be that strict but it could also be the issue. On your old webhost, you may have to add the ip of the new host to the spf record. Just add ip4:23.22.22.23  to the existing record right after “v=spf1 “(where the IP should be that of your new host)
  4. Try to send a mail after about 30 – 1 hour just to be sure!

You can now rest, mails are being routed correctly!

codarren at hackers dot mu

 

Sources:

migration featured image

Facebook Comments