How to Move Magento from Subdirectory to Root Directory
Powerful website, blog as well as online store starts from registering a domain name. It has a huge impact in the way human and search engines perceive a site and can greatly influence shop recognition. The best domain names are those that people can remember since they will protect your identity. Thats why it is really important to keep your domain name after shopping cart migration. Always ensure you have a solid security policy in place during any changes. In this article we are going to explain how to resolve common issues concerning domain names modifications in Magento shopping cart.


It is a common situation while migrating to Magento when e-merchant creates a test subfolder in a root folder. After that, installs a target shopping cart right there. As a result, store owner has a source store in root - www.mystore.com and target store in some subfolder - www.mystore.com/targetstore/. Accordingly, after migration is completed, target store will be located in a subfolder. Migrating SEO URLs carefully is crucial for preserving search rankings. Consequently, merchants face a dilemma. They want customers to type the www.mystore.com and see the live target store instead of typing www.mystore.com/targetstore.

So, how to solve this dilemma?

First of all you should enter your admin panel and go to System -> Config -> Web. There you will see settings for your “base URL”, which you will have to update.

Step 1. Set the default store to the proper “base URL”

How to Move Magento from Subdirectory to Root Directory

Please take into a consideration that the “base URL” has the subfolder defined.

Step 2: Set your store view “base URL” to the “root URL”

On the left you will see a drop down list where you will have to change the "Current configuration scope" to your store view (choose not default one).

How to Move Magento from Subdirectory to Root Directory

After that you have to change the “base URL” value. To do that simply uncheck 'use website' and enter your new “base URL”:

How to Move Magento from Subdirectory to Root Directory

Also, double-check in the same screen that your Session file management cookie path is set to the root folder of your site and that the domain is correct:

How to Move Magento from Subdirectory to Root Directory

Step 3. Copy files to your root directory

Last but not least. You will have to copy the index.php file, .htaccess file, and symlink your media, skin and js folders to your root directory, since they are only available to your subfolder Magento base install right now - you will need to let your main domain know where to look for Magento! From secure shell in your Magento installation directory www.mystore.com/targetstore as sudoer:

sudo cp index.php ../ 
sudo cp .htaccess ../ 
sudo ln -s js ../ 
sudo ln -s skin ../ 
sudo ln -s media ../

Note, your admin will still be available at mystore.com/targetstore/admin

Edit your index.php file in this main webroot (the file you just copied) and update it around line 45:

$targetstoreFilename = 'app/Targetstore.php';
Change this to:
$targetstoreFilename = 'cart/app/Targetstore.php';

Where 'targetstore' is the subfolder. Finally, you need to clear the cache for these changes to take effect.

Please take into consideration, such procedure will be suitable only in case you use the same server.

Need to move store database from one Magento to Magento migration store to a completely another one? Try out automated Magento migration using Cart2Cart, and get your data transferred in terms of several hours! For deeper insights into managing your migration, explore our additional migration options.

Monthly Update – January 2026

Welcome to 2026! As the new year begins, optimizing your e-commerce store's foundational elements, like its domain structure, remains a top priority. Moving your Magento installation from a subdirectory to the root directory, as detailed in this guide, is a crucial step for improved SEO and a more streamlined user experience. A clean URL structure signals authority to search engines and prevents potential canonicalization issues that can dilute your site's ranking power. This month, focus on auditing your site's technical health. Ensure all redirects are correctly implemented, especially after significant changes to your URL paths, to maintain link equity. Embrace the opportunity to refresh your site's backend for better performance, faster load times, and enhanced security. These efforts are not just about making a technical change; they're about future-proofing your online business against evolving search algorithms and customer expectations. A robust technical foundation is the bedrock of sustained online success in the competitive e-commerce landscape of 2026.

For more details, explore our FAQ section or schedule a call with a migration expert.