Update base URLs or change site name

Update base URLs or change site name
Last updated Nov 24, 2020

Cache Management Base URLs are one of the most important parts of Magento and they cause constant trouble for our customers. The good thing is, by knowing about them you will save yourself infinite time and feel like a wizard.

Within the Magento admin, these values can be viewed by going to System -> Configuration -> Web (from the left-hand menu), then expand the secure and unsecured accordion fields. You will see something like this:

Magento 1 panel showing how to update base URL or change site name.

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 customers have custom media/skin/js values for use with CDNs or other customization.

When a request is made to a Magento install, it will automatically redirect to whatever these values are, so you could update webscoot.io‘s base URLs to google.com and suddenly visitors to webscoot.io would always end up at google.com.

Knowing that you can see that set incorrectly they will redirect and cause strange behavior from the perspective of someone who is not aware of this, which is typical of customers. Subsequently, if a customer complains of a redirect problem, one of the first things to check after DNS is the base URL.

Updating the URL

Of course, we can always change an existing site by going through the admin, but we are better than that and half the time this is not possible because the problem is they will not be set correctly in the first place.  Therefore, we must go to the MySQL command prompt.  To view the base URLs via command line, try the following:

  • Navigate to the Magento web root
  • Find local.xml in app/etc/ and determine which database is in use by the store you are working on
  • Type “MySQL” to bring up the MySQL command prompt – alternatively, on MHM servers you can run n98-magerun.phar db:console to be taken directly to the proper database
  • Run the command use databasename; with the Magento database name
  • Run the query select * from core_config_data where path like "%secure%"; with a table prefix if necessary, you will get a big blob of values like this –

| config_id | scope   | scope_id | path                                    | value                                           |
+———–+———+———-+—————————————–+————————————————-+
|         4 | default |        0 | web/unsecure/base_url                   | https://webscoot.io/                            |
|         5 | default |        0 | web/secure/base_url                       | https://webscoot.io/                           |
|        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
+———–+———+———-+—————————————–+————————————————-+

You can also do this via phpMyAdmin if you prefer

Now to apply the above change, reindex (see Reindex Magento) and clear the site cache (see Cache Management)

  •  
  •  
  •  
  •  
  •  

0 Comments