1

Topic: Changing the Underlying Domain for Magento

Magento : Changing the Underlying Domain for Magento

Overview

There are a number of reasons you might want to change the domain name that Magento runs under.  The most common reason being in moving from a development domain to a live domain, but thats not the only reason, may people find it a lot less painful to convert an existing (working!) Magento to a completely different setup and product range rather than starting from scratch.

Complexity

Easy.

Suitable for:

Shared Hosting
VPS Hosting
Dedicated Hosting

Basically this guide works for any Plesk and Magento setup.

Requirements

Access to your Hosting Control Panel.
The ability to update DNS or nameservers on the new domain so it points correctly.

Howto :

As ever Nublue recommends that you backup your entire site using your Hosting Control Panel backup utility before undertaking any significant changes to your site.  We regard changing the underlying domain of your site to be a very significant undertaking

1) Ensure you have backed up your site in your Hosting Control Panel.  This method is robust and we have been using it for several years, but failure to follow it fully can have far reaching implications.

2) For Magento 1.4 Users Only : Ensure that System -> Configuration -> Web -> Redirect to Base URL if requested URL doesn't match it is switched off during these changes.  It shouldn't make a difference but I have a pathological fear of it as a "feature", its fine to turn it back on once the work is completed.

http://forums.nublue.co.uk/images/redirecttobaseurl.png

3) Change the domain within the Hosting Control Panel using the Domain Administrator button (Login -> Home -> your_domain.com -> Domain Administrator).  Simply edit the very first text box deleting the old domain and adding the new domain (without www.).  Ensure that the www is ticked if required.  Click OK at the bottom of the page (all other options on the Domain Administrator page should be left as-is).

4) We now need to change the base URLs within the Magento database through PHPMyAdmin (To get to PHPMyAdmin : Login -> Home -> new_domain_name.com -> Databases -> Database_name -> DB WebAdmin).

5) Once PHPMyAdmin has loaded (it opens within a separate browser tab/window) click on the table "core_config_data" in the left hand sidebar to open it up in the main frame (Note it might be that the table is prefixed with, either way the listing is alphabetically sorted).

6) Click on Search and for the form section that says path select the LIKE %...% option, then enter "secure" into the text box for path and click on the Go button.

http://forums.nublue.co.uk/images/phpmyadminsearch.png

7) For all the entries returned that contain the URL for the old domain name you need to edit each one and update the details to reflect the new domain URL (you must ensure you maintain the preceding http:// or https:// and any / or directory names on the end of each specific entry).  You can edit each entry by clicking on the appropriate pencil icon, making the change and saving.  For convenience I open each entry that requires editing into a new window and then work my way through each one saving as I go.

8) Clear the Magento cache using the Clear Magento Cache button in the Hosting Control Panel.

Thats it, assuming that DNS is correct for the new domain it should load fine when entering the new domain name in your browser.

Possible Issues :

The two most likely errors are typos when updating the URLs and failing to reset the cache.  Using the phpMyAdmin search facility check all the base URL entries with absolute URLs in them are spelled correctly (and have the preceding and following http(s):// and / respectively).

Reversing the Change

Just follow the guide but swap round old domain and new domain.

Other Options

This is the way that we change the underlying domain for Magento.  The primary benefit for us in this method is that we don't need Magento admin panel access to do it. You could change the baseURLs from within Magento's admin panel at Step 2 (System -> Configuration -> Web -> Unsecure and Secure Base URLs) and then skip Steps 4 to 7 but as soon as you Save the configuration your Magento store will break till Step 8 is completed.  We've not done this often so we can't vouch for how reliable a method it is.