How To Move An OpenCart Installation To A New Domain

 

How To Move An OpenCart Installation To A New Domain

 

The title says it all! In this tutorial we will be looking at how to move your OpenCart shopping website to a new domain whilst keeping all of your products, pages and data. It’s a few step process but one that lots of people ask me about so I thought I would put up a decent blog to walk you through it.

Surprisingly enough, it is actually quite easy to move your OpenCart store to a new server. A bit fiddly perhaps but it doesn’t require much in the way of hardcore development skills and anybody can jump through the hoops to get it done! So, lets start with backing up your data.

Step 1: Exporting Your OpenCart MySQL Database

This requires you to log in to your existing web hosting account and head to the PHP MyAdmin (or eqivalent) where your database is located. Then choose the “Export” option on the navigation bar at the top:

export_phpmyadmin

You will now be taken to an export option screen to choose the file format of the export file, what file this needs to be depends on the type of web host you are moving to but if they have PHP MyAdmin installed then you are safe with any. For peace of mind, I would recommend using the SQL format or CSV for Excel (Comma Separated Values) just for consistency as these are generally supported by any decent web server. Leave all other values as the default:

export_phpmyadmin2

Depending on how many products you have in the database you may find that the backup takes a while to download, don’t be worried. Remember that this database holds all of your OpenCart Products, Categories, Information Pages, Shop Options, Meta Data and other statements which are required for the E-Commerce system to run!

Step 2: Back Up Your Entire OpenCart Store

While that is downloading you should be creating a complete backup of all your OpenCart files and saving them to a folder on your computer. You can do this through your web host control panel or with an FTP program such as FileZilla. Make sure that you have every file on your OpenCart server backed up and then you can pat yourself on the back: you’re halfway to moving your OpenCart store to a new domain!

Step 3: Import Your OpenCart Database Into Your New Domain

Now that you have your files backed up it is time to move your database to the new host. Log in to your new web host and head to their PHP MyAdmin area and click on the “import” tab along the top of the page:

import_phpmyadmin

You will then be taken to a page where you can choose your OpenCart back up database file and make sure to choose the correct format you chose in Step 1. The PHP MyAdmin system will do all of the hard work by taking the data and making a new database with all of your old information! Easy, right?

Step 4: Reconfiguring Your OpenCart Website To Work On The New Domain

This is undoubtedly the trickiest bit of moving your OpenCart website to a new domain or server. Most people overlook it completely and then can’t find the original files and lose hope and delete everything. But stick with me, once again, it is just about jumping through the hoops!

You will need to open up two files from your back up of the OpenCart web pages. These files are:

  • [YOUR BACKUP FOLDER]/config.php
  • [YOUR BACKUP FOLDER]/admin/config.php

For each file you will be faced with two dozen or so lines of text which are defining root folders and MySQL Connection values etc. The only thing you need to do is replace them with your new domain paths! So replace the file lines with the following (remember to put your actual domain name where I have put “[YOUR NEW DOMAIN]”!) as I have shown step by step below:

The Standard HTTP root files

// HTTP
define('HTTP_SERVER', 'http://www.[YOUR NEW DOMAIN].com/');
define('HTTP_IMAGE', 'http://www.[YOUR NEW DOMAIN].com/image/');
define('HTTP_ADMIN', 'http://www.[YOUR NEW DOMAIN].com/admin/');

The Secure Connection root file path

// HTTPS
define('HTTPS_SERVER', 'http://www.[YOUR NEW DOMAIN].com/');
define('HTTPS_IMAGE', 'http://www.[YOUR NEW DOMAIN].com/image/');

The Global Directory Paths

// DIR
define('DIR_APPLICATION', '/catalog/');
define('DIR_SYSTEM', '/system/');
define('DIR_DATABASE', '/system/database/');
define('DIR_LANGUAGE', '/catalog/language/');
define('DIR_TEMPLATE', '/catalog/view/theme/');
define('DIR_CONFIG', '/system/config/');
define('DIR_IMAGE', '/image/');
define('DIR_CACHE', '/system/cache/');
define('DIR_DOWNLOAD', '/download/');
define('DIR_LOGS', '/system/logs/');

Your OpenCart MySQL Database Connection Details

// DB
define('DB_DRIVER', 'mysql');
define('DB_HOSTNAME', '[MYSQL HOST]');
define('DB_USERNAME', '[MYSQL USERNAME]');
define('DB_PASSWORD', '[MYSQL PASSWORD]');
define('DB_DATABASE', '[MYSQL DATABASE NAME]');
define('DB_PREFIX', '[MYSQL DATABASE PREFIX]');//The standard is "opn_" without quotes

Here is the full text if you want to just copy and paste it all in one go:

// HTTP
define('HTTP_SERVER', 'http://www.[YOUR NEW DOMAIN].com/');
define('HTTP_IMAGE', 'http://www.[YOUR NEW DOMAIN].com/image/');
define('HTTP_ADMIN', 'http://www.[YOUR NEW DOMAIN].com/admin/');

// HTTPS
define('HTTPS_SERVER', 'http://www.[YOUR NEW DOMAIN].com/');
define('HTTPS_IMAGE', 'http://www.[YOUR NEW DOMAIN].com/image/');

// DIR
define('DIR_APPLICATION', '/catalog/');
define('DIR_SYSTEM', '/system/');
define('DIR_DATABASE', '/system/database/');
define('DIR_LANGUAGE', '/catalog/language/');
define('DIR_TEMPLATE', '/catalog/view/theme/');
define('DIR_CONFIG', '/system/config/');
define('DIR_IMAGE', '/image/');
define('DIR_CACHE', '/system/cache/');
define('DIR_DOWNLOAD', '/download/');
define('DIR_LOGS', '/system/logs/');

define('DB_DRIVER', 'mysql');
define('DB_HOSTNAME', '[MYSQL HOST]');
define('DB_USERNAME', '[MYSQL USERNAME]');
define('DB_PASSWORD', '[MYSQL PASSWORD]');
define('DB_DATABASE', '[MYSQL DATABASE NAME]');
define('DB_PREFIX', '[MYSQL DATABASE PREFIX]');//The standard is "opn_" without quotes

The Admin Config file works exactly the same but you have to add the “/admin” element to each file location. Such as below:

// HTTP
define('HTTP_SERVER', 'http://www.[YOUR NEW DOMAIN].com/admin/');
define('HTTP_CATALOG', 'http://www.[YOUR NEW DOMAIN].com/');
define('HTTP_IMAGE', 'http://www.[YOUR NEW DOMAIN].com/image/');

// HTTPS
define('HTTPS_SERVER', 'http://www.[YOUR NEW DOMAIN].com/admin/');
define('HTTPS_IMAGE', 'http://www.[YOUR NEW DOMAIN].com/image/');

// DIR
define('DIR_APPLICATION', '/admin/');
define('DIR_SYSTEM', '/system/');
define('DIR_DATABASE', '/system/database/');
define('DIR_LANGUAGE', '/admin/language/');
define('DIR_TEMPLATE', '/admin/view/template/');
define('DIR_CONFIG', '/system/config/');
define('DIR_IMAGE', '/image/');
define('DIR_CACHE', '/system/cache/');
define('DIR_DOWNLOAD', '/download/');
define('DIR_LOGS', '/system/logs/');
define('DIR_CATALOG', '/catalog/');

// DB
define('DB_DRIVER', 'mysql');
define('DB_HOSTNAME', '[MYSQL HOST]');
define('DB_USERNAME', '[MYSQL USERNAME]');
define('DB_PASSWORD', '[MYSQL PASSWORD]');
define('DB_DATABASE', '[MYSQL DATABASE]');
define('DB_PREFIX', '[MYSQL PREFIX]');//Same as before with the "opn_" as standard

Notice that not all the file paths have the admin folder included, this is not a typo, it is the right way to put the file paths, so don’t include them if they are not shown here or you will get a MySQL error!

Step 4: Upload Your OpenCart Back Up Files To Your New Domain

Now that nightmare is out of the way all you have to do is upload all of your files to the new domain server and everything will work as on the past site. Remember that if you have put in custom links in the information pages (or edited the controller/template files) you will need to go through them and change the domain it is pointing to!

Apart from that, your new website is good to go! The good thing about this method is that it leaves the old one intact when the OpenCart site has been moved to the new domain! So, if you start getting all sentimental about your old domain it can still be there for old customers.

A Marketing Freebie

Here is an extra little tip for you out there are who are moving permanently to a new domain. Putting a 301 redirect can kicik Google into indexing faster and keeps most of the link juice from other sites that once pointed to your old domain and transfers it to your new domain. It can be an easy way to inform Google that you have moved domain and to keep you listed at a similar level on the SERPs (Search Engine Results Pages). In addition it does the standard task of redirecting customers who go to your old domain to your new OpenCart location!

Open up this file from your old OpenCart site and make the changes shown below:

  • /catalog/view/theme/[YOUR THEME]/template/common/header.tpl

This will send all of your customers to the new domain location and pass on all the links pointing to your old website to the new one as well! If you don’t think this is relevant, think of all the people who might have bookmarked, written down or click on their history to get to your site rather than typing out the full address in the URL bar in their browser. For two minutes work, it is always worth redirecting to your new website!

Struggling to move your OpenCart store?

Tutorials like these can sometimes feel daunting, if you want your OpenCart store moving then we can help. Destrove can help you move your OpenCart website onto a new domain, web hosting account or folder for a low Micro Service fee, we have worked on dozens of OpenCart projects and can move your OpenCart store across smoothly and safely.

How To Move An OpenCart Installation To A New Domain

How To Move An OpenCart Installation To A New Domain

Leave a Reply