Transfer Site to New Server - Redirect Old Site to New IP Address?

jethrodesign

Well-Known Member
Feb 17, 2012
67
2
58
cPanel Access Level
Root Administrator
Hi,
We're transferring a lot of accounts to a new server. We use the 'Express Method' and when the DNS records exist on the old server and we set the TTLs real low ahead of time the transfer is nearly instantaneous.

HOWEVER, a couple sites have DNS that is managed elsewhere with only an A record pointer. The problem is that we've experienced some pretty large delays in everything propagating to the new server on different connections. The site we're dealing with currently has DNS hosted by Yahoo Business. We edited the A record there shortly after the transfer, but it's been 2 days and the client called to complain that a customer was still seeing the 'Site moved' page that is linked in the .htaccess file. When we test the domain at DNSTools, the new IP shows.

We know that DNS can take a while to propagate, caches may need to be cleared, etc. But no average customer is going to know that and our client may be losing business in this 'downtime'.

- Is there a way to set a redirect in the OLD SERVER'S .htaccess file that would send the user to the new server (instead of the 'Site moved' page)? If so, let me know the syntax, I'm not great with .htaccess commands.

I know I can get to the new site by going to: 'http://ip.ad.dre.ss/~accountname. This takes me to a 404 page on the new site, but it's easy to get around from there. Or I wonder if a redirect could be set on the new site for that issue?

- Any way to implement this in .htaccess or otherwise so there will be NO chance of anyone hitting the old server while we wait for things to propagate?

- How long has anyone seen an A record change take to redirect in a 'worst-case' scenario? The client wants to know when this will clear up.

THANKS!

Kenny
 

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,880
2,267
463
Hello :)

The problem with using the Mod_Userdir (~) URL is that it's often not compatible with websites that use scripts with custom Mod_Rewrite rules. Have you had the customer try to clear their DNS cache to see if that speeds up the propagation? This is documented at:

cPanel - Clear DNS Cache

Two days sounds like a long time for propagation from most locations. Have you considered switching the name servers from the registrar name servers to the name servers for the destination machine?

Thank you.
 

jethrodesign

Well-Known Member
Feb 17, 2012
67
2
58
cPanel Access Level
Root Administrator
Hi, thanks for the reply.

Our client, who is fairly tech saavy did follow the instructions to clear their DNS cache but still had issues. I had to walk them through how to clear browser cache as well. UNFORTUNATELY, we can't be available to walk every one of their customers through this process! An average Joe may not even read it too carefully and assume the site is just disabled or they've moved. While we understand the tech behind the message, it's not very elegant for the average customer.

We cannot move their name servers to ours as their email is hosted by Yahoo. So they want to keep it all there (which makes more sense anyway).

I'm not hugely concerned about the Mod_Userdir URL giving a 404 page, as we've styled those and include links to the home page. As this is HOPEFULLY just a very temporary solution for random people who's DNS servers haven't refreshed, it's better than the current situation. I just don't know the syntax to make it happen.

Thanks!
 

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,880
2,267
463
Here is an example of an entry you can use in the .htaccess file of an account on the source server to redirect the pages to a Mod_UserDir URL:

Code:
RewriteCond %{HTTP_HOST} ^.*$
RewriteRule ^(.*)$ "http\:\/\/123\.45\.567\.89\/\~username\/$1" [R=301,L]
Thank you.
 

jethrodesign

Well-Known Member
Feb 17, 2012
67
2
58
cPanel Access Level
Root Administrator
Thanks for the snippet! We'll use this when we have issues with sites not updating quickly.

We've already deleted the old site for this particular site, so we won't test it here (we assumed it should be clear after 4-5 days). But this is good to have for the future.

Thanks again.
 

GoWilkes

Well-Known Member
Sep 26, 2006
703
34
178
cPanel Access Level
Root Administrator
FYI, I'm having a very similar issue. When the domain is registered with NetSol or GoDaddy and the owner uses their "Privacy Protection", it's a real problem. I've been waiting for 2 weeks for them to update! If they don't update by the end of the month, I'm going to have a problem. I'm not paying for the old server for another month, just because a couple of domains haven't updated.

In our case, it's not a browser issue, because DNSStuff and IP-Lookup.net both show that the domain is pointing to the old IP. So it's definitely an issue with the domain's DNS.

Using the script that Michael posted is fine, but I believe it will actually show the user the redirected IP, which may not make the customer too happy. You can try using mod_proxy, like so:

RewriteEngine on
RewriteRule ^(.*)$ http://123\.45\.67\.89/~username/$1 [P,QSA,L]

I haven't tested that, but it should work if mod_proxy is installed on the old server.

On my end, though, I've been using CURL, which is working better and faster. This relies on two things; this in the .htaccess:

RewriteEngine on

RewriteCond %{REQUEST_URI} !(jpg|png|gif) [NC]
RewriteRule ^(.*)$ redirect.php [QSA,L]

Then a file named redirect.php in the /public_html/ directory:

<?php

function get_content($URL) {
$ch = curl_init();
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_URL, $URL);
$data = curl_exec($ch);
curl_close($ch);

return $data;
}

echo get_content("http://123.45.67.89/~username" . $_SERVER['QUERY_STRING']);

?>

This will import the new data invisibly, but it's still going to be slower to load since it goes through two servers.

Regardless, this is all a temporary solution, until the domain updates. I don't know any way to make them move faster, but if you can find a way then please share it! :-D