Move Magento To Another Directory

Last modified by ircsome on Wed, September 19, 2012 08:28
Source|Old Revisions  |  Back To Group

If you’ve installed Magento in a subdirectory or even the root web directory and would like to move it somewhere else, here is how you do it.

Let’s say you have Magento installed in the following location:

http://www.yourdomain.com/store/

And you want Magento to be the first thing that comes up when visitors go to your site:

http://www.yourdomain.com

We’ll assume you have a directory structure like this:

/home/username/public_html/

Meaning Magento would be installed here:

/home/username/public_html/store/

First, login to the backend of Magento and go to:

System -> Configuration -> Web

Update the Unsecure and Secure URL for your store.

Also you can change the path directly with SQL (for example with phpMyAdmin or mysql command):

UPDATE core_config_data SET value = 'http://www.yourdomain.com/'
WHERE path = 'web/unsecure/base_url';

UPDATE core_config_data SET value = 'https://www.yourdomain.com/'
WHERE path = 'web/secure/base_url';

Next, connect to your site via SSH and go to the directory where you will be moving Magento:

  1. cd public_html/

Now, move all the files from the store directory to the directory you’re in:

  1. mv store/* store/.htaccess .

Delete the cache data:

rm -rf var/cache/ var/session/

And you’re done. Magento has now been moved up one directory.

If you visit your site and it doesn’t look like the theme is properly coming up, you might need to check the unsecure and secure values again. Please see this article to learn how to update these values.

Note: Unintended consequences. The above procedure will work great, but don’t forget that your url structure has now changed and your search engine link juice will dry up. Make sure that you have a 301 redirect strategy in place if this is important to you - that is, your site is already established and you rely on the search engines for some of your traffic. Thank heavens, I have Crucial hosting me, as they helped me sort this out.




 

Magento 2 GitHub Repository

Magento Job Board - Some sort of tag line goes here

Latest Posts| View all Jobs