How to change Magento domain name

When you need to move Magento store to another domain name, there is one issue which, according to forums, costed developers hours of frustration. And the issue is domain name which is stored in Magento configuration tables.

So, if you moved Magento to another domain name and all you get when you open your new domain in the browser is redirect to the old domain, you are not alone :) I just wasted lots of time sorting this out! Here is solution which worked for me.

First step was simple – finding in the database base url value: table name is core_config_data and the keys are /web/unsecure/base_url and web/secure/base_url. Change those two to the proper values.

Second step is also very logical – cleanup cache! Magento does cache everything, including values of config table, so go to the Magento root with FTP or SSH, remove everything from the folders var/cache/ and var/session/.

At this point changing URL seems to be working for most installations, so if you are lucky, that’s all you have to do. For me it was just a start :) Magento was redirecting to my old domain name. Browser cache cleanup – doesn’t help. APC cache cleanup – doesn’t work. Still redirecting…

Solution was simple (well, as usual with problems like this). Permissions were messed up on the var folder of Magento, so it was not able to write cache there (result of files transfer). That issue doesn’t stop Magento from caching (which is kinda good), but trick is that you need to find where the cache is hidden. So, check your tmp folder. It could be system /tmp/, or, in my case, /var/www/tmp/ (that was FreeBSD). In the temp folder I discovered magento subdirectory with all the cached files. After removing files, I see my site up!

Let me know if that helped you or if there are some other issues to watch for!