Fixing the Base URLs for Magento

If you move your Magento installation or change it’s hostname, the website will not be accessible.

This is how you bring it back up. This tutorial assumes you can log onto your server and have read/write access to your database.

1. Log into your MySQL database

Log into your MySQL database, replace $USER with your database user name and $DBASE with your database name. It will prompt you for your password:

mysql -u $USER -p $DBASE

If you do not remember your magento database name, try:

show databases;

and then:

use $magento_database;

Below are the SQL commands to change your base_url values. Replace unsecure http://www.example.com/ and secure https://www.example.com/ (if you have SSL/TLS enabled, else https should be http) with your appropriate domain url (trailing slash necessary) and if you’ve installed in a subfolder append it with a / after it.

2. SQL Commands

UPDATE core_config_data SET value = 'http://www.example.com/' WHERE path LIKE 'web/unsecure/base_url';
UPDATE core_config_data SET value = 'https://www.example.com/' WHERE path LIKE 'web/secure/base_url';

Check your base_url settings with the following:

3. Check correct results

SELECT path,value FROM core_config_data WHERE path LIKE 'web/unsecure/base%';
SELECT path,value FROM core_config_data WHERE path LIKE 'web/secure/base%';

Clear contents from var/cachevar/session directories after changing base_urls. Clearing cache and sessions is necessary because your config is cached and clearing it forces a reread of the configuration data from the core_config_data table and reestablishment of sessions with the proper information.

Leave a comment

Your email address will not be published. Required fields are marked *