HOSTINGTRICKS

Changing Web Hosts - Tips on Moving Your Website

by Christopher Heng,
If you have never moved your website before, you will probably think that it is a rather trivial matter. Certainly something that does not warrant an article — after all, it's only a matter of copying files over to the new server. Or is it?
Actually there's more to it than meets the eye. I have moved one of my other websites, many times in its rather long history, both with changes in the URL (back when it was without a domain name) and when I moved the actual domain between web hosts. It seems to me that each time I move, I overlook some important aspect.
I'll deal with both the mundane aspects — the checklist of things you need to do — as well as the more problematic situation of helping you minimise ("minimize" in US English) your loss of visitors.
Note that there are some differences between moving your site when you have your own domain name and moving it when you do not. I'll try to cover both these cases in this article.

Copying the Files (the Easiest Step)

The funny thing about websites is that no matter what everyone recommends officially, there continues to be people (more than you think) who actually only maintain only one copy of their website — the one on the web server.
If you're one of those, make sure you make a copy of your website on your computer. This has to be done even BEFORE you inform your old web host that you are terminating. In fact, it may be wise NOT to tell your old host that you're terminating just yet, since some people who run web hosts react badly. They might terminate your account before you're ready, throttle down your bandwidth or other such petty things. If you don't believe that such things happen, just browse the various webmaster newsgroups and you'll see that even worse things occur.
To copy your files, just use the method that you normally take to upload your files, and download them instead. If you do it through FTP, then copy them through FTP. If you use a browser to access your site via your web hosts' online "File Manager" (or the like), then do it that way.
If you're on a free server with advertisements (pop-ups, banners or otherwise), you should not simply connect to your site with a browser and save the page you see. Such pop-ups and banners are normally issued by the server modifying your web pages on the fly to add some additional JavaScript code to generate the pop-ups. When you save it the normal way your visitors do, you're also saving the pop-up code the server adds. Of course you can simply edit the file to delete it later - but why give yourself extra work?

Check Your Internal Links

The next step is to check all your internal links to make sure you do not have any hardcoded URLs pointing to the old address. This is not a problem if you have your own domain since your web address will not change in that case.
If you don't have your own domain, you might want to consider making all your internal links relative links to simplify your relocation process. You can always hardcode links again later if that's what you prefer.
If your old web host forced you to add some banner code or text link to your pages, this is a good time to delete them.
Note that your old site is still active. At this point, no one knows you're going to shift yet (except of course you and your new host).
Upload your pages to your new host. Test all your pages. Make sure they work. Remember — you have not yet officially shifted. If you have your own domain name, you have also not yet updated your DNS to point to your new host, and you'll probably have to test the new site using the temporary web address or IP address given by your new web host. The whole point of this exercise is to make sure everything is functional on both ends.

Update Your DNS Records (Domain Name Holders Only)

If you have your own domain name, update the DNS records with your registrar only when you're satisfied that your new site works as intended.
If you have a new domain name (and you did not have one previously), simply point the domain name to the new host. Do NOT point the domain to your old host first for fun. This will cause additional complications as well as delays in domain name propagation. Propagation seems to be faster when you're pointing a brand new domain than when you're switching a domain between IP addresses.
Although the registrars tell you that the update should be completed within 48 hours or so, in practice it may take a bit longer than that for all the name servers around the world to catch up with the new location of your domain. In that interim, only some parts of the world will be able access your domain at your new host; the rest will continue to access the old site. Note that even if you see the new site in your browser, it is not necessarily true that others will see the new site. This is normal — do not worry.
Do not, at this time, do the following:
  1. Do not delete the old site during this interim. This will help you avoid losing visitors. Just maintain two copies of your site. Endure the inconvenience for this period — it's only a short term hassle.
  2. Do not tell your old host just yet. Give it at least one week where both sites continue to run concurrently. This applies even if you're paying both hosts monthly fees. Plan to have both sites up for at least that week.

The New Site is "Live" — What About the Old?

After the week (where you maintain identical copies of your site on both your old and new host) is up, what you do next depends on whether you moved your domain name or whether your URL changed when you changed web hosts.
  • If you moved your own domain...

    If you had your own domain name previously, which you moved with your site, you have little else to do. You can simply terminate your account with your old web host, and you're done. If you can afford it, wait a week or so longer to make sure that the DNS records for every internet provider and search engine have been updated. Your visitors will probably not even know that you changed hosts. Your search engine listings are not affected since they still point to the right place: your domain.
  • If you are changing URLs...

    If you have been hosting with free web hosts or your old internet provider without your own domain name previously, you're now faced with the prospect of losing visitors. Visitors will be lost because they will follow old links to your site (whether from search engines or other sites) and will not find it there. Some loss of visitors is actually unavoidable, but you can do much to reduce the number lost.
    The best solution I can think of is to modify your old site's .htaccess file. Some web hosts allow you to put a .htaccess file in your web directories telling your web server what to do when a visitor tries to access a file on your site. This is actually just a plain text file that you can create using a simple text editor. If you use Windows, you can use Notepad for this task. (Don't use a word processor like Microsoft Word, Wordpad, or the like.) Check your old web host's documentation to see if this can be done. In general, only web hosts that use the Apache server will have such a facility.
    For each page that is under the old URL, put a Redirect statement pointing it to the new location. Take the following line for example:
    Redirect permanent /oldfilename.html http://www.example.com/newsitefile.html
    Every time your visitors try to access oldfilename.html on your old site, the server will tell their browser to load newsitefile.html from your new site (given as "www.example.com" in the above illustration) instead. They will then be transparently redirected to the new host without the requirement that they click on a link, etc. If they do not look at the location bar in their browser, they might not even know that they had been redirected.
    Search engines like Google, it is claimed, will also follow the link to index the new address, and treat the new page as a replacement for your old one. Some of the rank associated with your old page will also be transferred to the new. I don't know if all search engines do this automatically though. Like I said, there will be some losses: you can only reduce them, not avoid them altogether.
    If you're afraid that you might accidentally forget to list some page in your list of redirections, you can put a simple catch-all that redirects any remaining URLs to your new main page. The catch-all is probably only useful in catching humans that arrive at your site, and won't help you with your search engine listings. It involves simply redirecting all file not found errors to the main page of your new URL (given as "www.example.com" in the code below).
    ErrorDocument 404 http://www.example.com/
    If you don't have access to your old website's configuration files to do the above, the next best thing is to modify your old web pages to include the following line in the <head> section.
    <meta http-equiv="refresh"
    content="0; URL=http://www.example.com/file.html" />
    The "0" in the line specifies that the browser should wait 0 seconds before redirecting. If you want to display some sort of message, you can always change that to (say) 5 to tell the browser to wait 5 seconds. The tag would then read:
    <meta http-equiv="refresh"
    content="5; URL=http://www.example.com/newsitefile.html" />
    Even if you wait "0" seconds, you should still include some sort of short message in the body of your web page together with a clickable link to the correct page on your new site, just in case your visitors have disabled automatic redirection in their web browsers. A visible, clickable link will give these people an alternative way to get to your actual page.
    Note that "0" and the new URL are part of the same string that is assigned to the "content" attribute. The opening inverted commas (ie, quotation marks) are before the time ("0" in our case) and the closing inverted commas are after the URL. The URL itself does not begin with any quotation marks.

Updating Links on Other Sites

If your web server (old and new) has web logs, or if you have a statistics counter that tracks referrals to your website, make a list of all the sites that sent visitors to your site. Visit those sites and see if they are still using your old URL. If so, you might want to inform the webmaster of that site of your new address.
You will probably also want to submit your new URL to the search engines. Note that some search engines take forever to list a new site, so you just have to be patient.
Incidentally, you can search for links pointing to your old address by entering either that old URL or the name of your website into the search engine and look at what turns up. In the case of Google, it is possible to search for links to your site by preceding your URL with a "link:" prefix. For example, if your old address was "http://www.example.com/filename.html", typing "link:http://www.example.com/filename.html" into the search field will yield a list of some of the pages linking to that page.
How much time do you have to update the links? It really depends. If your site was previously on a commercial web host, you have as much time as you want, as long as you continue to maintain your old hosting account where you can set up redirections to your new URL. On the other hand, if your old account was situated on a free web host, it will only be for as long as they let you keep that account. Some free web hosts, especially the smaller ones, will notice that an account has gone dormant and prune it from their system. Redirection pages also tend to lose some people along the way (not everyone follows the redirection).
My experience is that it is very difficult to exhaustively remove all links pointing to your old URL. Some webmasters can't be bothered (particularly the webmasters of sites that have not been updated for years); some cannot be traced (no email address on the site); and sometimes you fail to notice the odd site or so that rarely sends you traffic. Till this day (in 2001), I'm still receiving redirected traffic from my very first web host set up in 1996 for (the predecessor of).

Conclusion

In general, no matter what you do, if you're changing URLs, you're bound to lose some visitors. Hopefully, the tips given above will help you reduce your losses in the confusion surrounding the move. At the very least, you will have avoided some of the problems I encountered when I moved my sites.