How To Migrate Magento From Folder

In this guide we will learn how to transfer a magento installation from a folder to the root directory. For this instance we will use the public_html as the root directory. (for a main domain NOT addon domain)

Create a copy of the files

We need to copy all files from the Magento website’s document root to the destination folder which is the public_html in this case. Remember to ensure that the .htaccess file is part of the files that you have copied. If you cannot locate the .htaccess file in the root folder, click on settings at your top right, then check ‘show hidden files’ and save

Create a copy of the database

Once you have the files copied to the root folder, now it is time to export your database. Look out for the following further steps for more details depending on the Magento version that you are using.

For Magento 2.x

In case you have a number of databases and you are not certain the name of the database that you ought to export, be sure to check out on env.php

To export it, you may follow the instructions here. After you have your data exported, create a new database and import the content in it.

For Magento 1.x

In case you have a number of databases and you are not certain of the name of the database that you ought to export, be sure to check out on the local.xml file.

To export it, you may follow the instructions here. After you have your data exported, create a new database and import the content in it.

Reconfigure Magento accordingly

Now you need to alter the configuration file in order to match the new settings. So you will change the database details at the new location as follow:

For Magento 2.x

In your file manager, access this path file and edit the following lines app/etc/env.ph:

‘host’ => ‘localhost’,

‘dbname’ => ‘db_name’,

‘username’ => ‘db_user’,

‘password’ => ‘dbpassword’,

For Magento 1.x

Here, you need to access this path file and edit the following lines app/etc/local.xml:

<host><![CDATA[localhost]]></host>
<username><![CDATA[db_user]]></username>
<password><![CDATA[dbpassword]]></password>
<dbname><![CDATA[db_name]]></dbname>

Once that is done, you now need to update the magento URL Your Magento should now be properly functioning at the new location.

Was this article helpful?

Related Articles

Leave A Comment?