Current magento version – 22.214.171.124
I’m guessing that quite a few people will have done what I did when I initially set up Magento, which was to just move the magento folder into my required document root and then go in and run the installer.
Logically all the files then got installed into that magento folder resulting in all my urls having “/magento/” in them which wasn’t exactly ideal. Of course this fact only registered with me once I’d done quite a bit of work, so the idea of doing a fresh install to sort this out was extremely unappealing to me.
Luckily for me it is possible to change the magento root from “/magento/” to “/”, but as you might imagine this sort of thing is fraught with danger (if that’s not too dramatic).
So I will stress here that it’s best to setup your root folders correctly on install, or run a fresh install if you can. But if you really need to change the root after the event then here’s what you have to do:
- Move all you files into your new document root (so out of the magento folder).
- In the magento admin panel, go to System->Configuration->Web and change the URL’s in the ‘Unsecure’ and ‘Secure’ tabs to take account of this change.
These steps should allow to access your site using the new root folder and URLs, so far so easy. However you will also need to change the pear setup to ensure that any extensions you download will get installed in the right place. So:
- Open up the downloader/pearlib/pear.ini. Search this file for all file/folder references and change these so that they match your new folder structure. NOTE: you will also have to change the number that appears infront of each reference as this needs to match the number of characters in the string. So in my case I had to take off 8 each time as I was always removing “magento/” from the string.
- I also changed the following files as they also referenced the old root:
Obviously this course of action is open to many possible mistakes and errors as you have to make sure that all the files are moved and referenced correctly, and if something goes wrong it is very hard to try and track it down.
So at the risk of repeating myself one last time it’s definitely best to do a clean install if possible, but if done correctly this should work.
Just remember to do a full backup first!