Stratus Guides - Updating Base URLs

Base URLs are one of the most important parts of Magento. Learn how to change them via the MySQL database.

Base URLs are one of the most important parts of Magento and they can cause serious trouble if not entered correctly. The following is a remedy you can use to easily correct Base URLs that have been incorrectly entered.

Within the Magento Admin, Base URLs exist within the Stores > Configuration > General > Web panel.

ssh info-2

Note that only two fields have an actual URL, the rest have placeholder variables that file in the domain automatically. This is typical of every Magento install, though some configurations have custom media/skin/js values for use with CDNs or other customizations.

It is easy to see that setting the Base URLs incorrectly will redirect and cause a strange behavior. If you have a re-direct issue with a Magento store, first check the DNS records to make sure the DNS is set up correctly, then review the Base URLs.

Update the URLs

While the Base URLs can always be updated by going into the Magento Admin panel, sometimes, the Base URLs are so misconfigured that accessing the backend doesn’t work.

Therefore, you can access the Base URLs stored in the core_config_data table of your Magento database.

  1. Access your Magento install via SSH.
  2. Navigate to the Magento web root (typically, public-html/).
  3. Run n98-magerun db:console (Magento 1) or n98-magerun2 db:console (Magento 2).
  4. Run the query select * from core_config_data where path like "%secure%"; (you may need to use a table prefix, if necessary). The results should appear similar to this:
config_id scope scope_id path value
4 default 0 web/unsecure/base_url http://magemojo.com/
5 default 0 web/secure/base_url https://magemojo.com/
13 default 0 web/unsecure/base_link_url {{unsecure_base_url}}
14 default 0 web/unsecure/base_skin_url {{unsecure_base_url}}skin/
15 default 0 web/unsecure/base_media_url {{unsecure_base_url}}media/
16 default 0 web/unsecure/base_js_url {{unsecure_base_url}}js/
17 default 0 web/secure/base_link_url {{secure_base_url}}
18 default 0 web/secure/base_skin_url {{secure_base_url}}skin/
19 default 0 web/secure/base_media_url {{secure_base_url}}media/
20 default 0 web/secure/base_js_url {{secure_base_url}}js/
21 default 0 web/secure/use_in_frontend 1
22 default 0 web/secure/use_in_adminhtml 1
23 default 0 web/secure/offloader_header SSL_OFFLOADED
464 default 0 carriers/usps/gateway_secure_url https://secure.shippingapis.com/ShippingAPI.dll
717 default 0 kbase/url_rewrite/secure_urls 0
768 default 0 google/checkout/use_secure_callback_url 0
  1. The notable values are at the top. To change them to another value (e.g., example.com), run a query such as update core_config_data set value="http://example.com" where config_id=4;
  2. Repeat the above query and use “https” where required. If the size is a multi-store with multiple value, you may have to do this query several times.
  3. To apply the changes, reindex the Magento installation and clear the cache.

Last modified January 1, 0001