How to change Base URL in Magento
Sometimes it may be essential to change the BASE URL of Magento.
(Usually when you want to make a similar copy of Magento on another server!)
There are 2 – 3 simple steps involved in this:
Step 1: Edit old URL values in database
Table: core_config_data
In this table you need to edit the field named value containing specific values in the field named path!
Precisely saying you need to search for web/unsecure/base_url and web/secure/base_url and replace them with new values.
Please refer the images for an example.
OLD Values:
Step 2: Login to backend and clear Configuration cache!
This might be simply not possible and hence skip to next step!
Step 3: Find All entries of old domain name in the cache folder and replace them one by one.
Magento retains all configuration cache in /var/cache folder.
This step is good for Advanced Users who can do file search and replace such strings in one shot
If you are migrating a very big site, then this step will be certainly worth.
I use this “Unix Find Command” very useful in searching:
find . -exec grep -q www.magdummy.cws '{}' \; –print
Step 3: Now it’s time to clear the cache! (Normal User)
As already specified in step2, we know that Magento retains all configuration cache in /var/cache folder.
You can clear the entire contents in this cache folder. Magento regenerates all these files when needed.
Step4: View your new site in the browser.
It should now be working fine like the old one
I hope this would work fine for you.
Please leave your comments or I would appreciate any idea that suits best in this case.

14 Comments










June 15th, 2009 at 3:06 pm
Hello I changed the {{base url}} for my online bookstore and I can not change it back. I can not connect to admin area either.
Can you please help me?
June 15th, 2009 at 3:15 pm
Hi Serena,
I believe you changed the URLs through the database.
After changing the URLs kindly ensure that you cleared the cache folders.
Regards,
Prakash
June 15th, 2009 at 3:17 pm
I change the {{base url}} from admin page in my college textbooks online bookstore.
from http://www.cocomartini.com/bookstore/
to http://www.cocomartini.com/bookstore/collegetextbooks/
now i am not able to login admin again
July 27th, 2009 at 2:55 am
thanks for the easy to follow explanation. It worked like a charm. I skipped steps 2-3 and went to 4.
August 7th, 2009 at 11:32 pm
[...] quick howto that complements chandansweb’s article on how to change the Base URL using phpMyAdmin. On production servers I do not install phpMyAdmin and therefore I need to use command line. Here [...]
September 1st, 2009 at 7:32 pm
Hi I am so glad that you all found it useful
September 17th, 2009 at 7:13 pm
Video would be nice to see how to do that.
December 15th, 2009 at 9:53 am
Excellent Magento “how-to”. Like Vicky, I just used steps 1 and 4 and it worked great.
Thanks!
December 15th, 2009 at 10:08 am
Douglas, That is great.
I am quite happy that this has been quite useful.
Thanks for all your comments.
December 30th, 2009 at 5:38 pm
Thanks, worked great !
January 3rd, 2010 at 4:12 pm
Thanks man, worked without a problem.
I had disabled the cache in the back-end system/cache-management before renaming, so I could go directly from step 1 to step 4.
This saves a lot of work!
January 3rd, 2010 at 10:44 pm
After changeing URL i had some trouble with wrong path in /downloader/pearlib/pear.ini, this caused Magento Connect to install extension in the “old” directory.
I did the following to solve this problem:
1) Take a backup of the file /downloader/pearlib/pear.ini
2) Delete (or rename) pear.ini
3) Go to Magento connect manager – the settings are resteted back to “stable”, change it to beta and press save. A new pear.ini file should now be created with the correct path.
4) Done
Good luck!
January 27th, 2010 at 5:20 am
Lazzo – thanks for that hint. None of the migration instructions I have seen so far even mention this. This is a very necessary step, and without it Magento Connect Manager shows up no packages available.
– Jason
February 9th, 2010 at 10:36 pm
Thanks, this worked brilliantly, although I needed to change the name of the directory into which I installed magento. (This was not mentioned in the description above, but is an important step for it to work.
)
And without the captcha I lost all my entered data, I’m so happy I wrote this twice.