Fixed It: Magento Base URL Changes Did Not Reflect on the Frontend.

Want the TLDR? Use magerun as a helper and checkout the Summary.

Arriving at the office this morning, I learned that as I camped in my daughters fort last night, our AWS CloudFront CDN started throwing 502 errors. Not a big deal right? Just log into the backend, change the base URLs for our static assets, and clear the cache. Of course, it’s going to require more than that.

Step 1: I logged into the backend, and the UI has broken down since it depends on the javascript that’s being loaded via the CDN. Alright, let’s do this the good old DB way…

Step 2: Using my handy dandy magerun helper, I quickly updated the CDN URIs.

$ magerun mysql
$ mysql > SELECT DATABASE(); /* Just a bit of reassurance that magerun placed us in the right database */
$ mysql > update core_config_data set value='' where value='';
$ mysql > update core_config_data set value='' where value='';
$ mysql > update core_config_data set value='' where value='';
$ mysql > exit;
$ magerun cache:flush

Cache cleared and good to go, right?! Nope. Javascript and most CSS is rendering correctly, however, a number of paths within the Network tab of the Google Console are returning CDN 502 errors.

Step 3: It appears that some of the assets are being referenced by merged CSS, let’s turn that off:

$ magerun dev:merge-css --global
/* Heck, we're trouble shooting, so unmerge JS as well */
$ magerun dev:merge-js --global

Alright, we’ve made some progress! My homepage is rendering normally on desktop, however, there are a few more media paths in the Google Console that are still pointing to our CDN.

Step 4: Locate the last of rogue paths. I want to make quick work of this, so, let’s search via the console for template files with hard-coded paths:

$ grep -r --include *.phtml 'cdn' ./

No, results? Damn I’m good with my template paths. Maybe they’re living in my site sliders, CMS blocks, or CMS pages? Let’s check.

# Our main CMS content is contained within a slider module, CMS Blocks and CMS Pages.
magerun mysql
$ mysql > select page_id from cms_page where content like "";
$ mysql > select block_id from cms_block where content like "";
# And our Slider Module - you'll need to consider where your content lives
$ mysql > select slider_id from auguria_sliders where cms_content like "";

And here it all is. These queries returned a number of results letting me know where my CDN path was hard-coded. Shame on me, I know.


You’ve updated your base URLs in Magento but still do not see the changes reflected in the UI. Consider the following:

  1. Disable merged CSS and JS. You could clear the cache, but you’re trouble shooting, just disable it as well.
  2. Search your template files for your hard-coded CDN URL. The grep command within terminal makes this quick and painless.
  3. Search your database, namely your cms_block and cms_page tables, for your hard-coded CDN URL. You know which other extensions you may be using to manage content (such as sliders), so check their DB tables as well.