How to move the store to another domain

This tutorial will show you how to transfer your website from one domain to another.

In order to transfer your site to another domain you need to perform the following:

  • Export database from your PhpMyAdmin tool;
  • Change the links in the config.php and admin/config.php files;
  • Zip the content of your OpenCart installation folder.

First of all, export your database from the PhpMyAdmin tool. You will receive an SQL file which you will need to import to your new host. However, this step is optional in case you transfer the site within one host, for example from the sub-domain to the main domain. In such case, you may leave it unhandled.

Secondly, two files has to be amended: config.php and admin/config.php which contain the links to your site.

config.php:

Change your link on the ~line 3 change your URL as well change it on the ~line 6 if you have SSL certificate on your site (https connection).

Now, you need to amend 3 variables which contain path to your catalog, system and image folders.

One the ~line 9 specify the path from your home directory to the catalog folder, example – /home/domain/public_html/catalog/

One the ~line 10 specify the path from your home directory to system folder, example – /home/domain/public_html/system/

One the ~line 11 specify the path from your home directory to image folder, example – /home/domain/public_html/image/

define('DB_DRIVER', 'mysqli');
define('DB_HOSTNAME', 'localhost');
define('DB_USERNAME', 'mysql username');
define('DB_PASSWORD', 'password’);
define('DB_DATABASE', 'database name');
define('DB_PORT', '3306');
define('DB_PREFIX', 'oc_');

Now you should specify the details to the database if they were changed in the following block of code:

admin/config.php:

Change the link to your admin panel on the new domain ~line 3 and on the next line, specify the link to your new domain.

On the ~line 7 and ~line 8 change the URL to your new admin and site URL with secured connection (https connection).

Now on the ~line 11 specify the path from your home directory to the admin directory.

On the ~line 12 specify the path from home to system directory.

On the ~line 13 the path should be from your home directory to image directory.

On the ~line 15 specify the path from home directory to catalog one.

Now you should specify the details to the database if they were changed in the following block of code:

define('DB_DRIVER', 'mysqli');
define('DB_HOSTNAME', 'localhost');
define('DB_USERNAME', 'mysql username');
define('DB_PASSWORD', 'password’);
define('DB_DATABASE', 'database name');
define('DB_PORT', '3306');
define('DB_PREFIX', 'oc_');
Note that the databases info should be the same in both config.php and admin/config.php files.

Also, it is very important that all your paths and links in these files end with slash because your links will not resolve properly.

Do not forget to make sure that you have imported your sql file as was mentioned on the first step.

Now once you changed these two files, zip all the content and transfer it to the new domain. Unzip the files and check your new URL.