I recently switched a Magento 2 system from serving public files out of


to serving files out of


i.e. I wanted Apache to use the index.php file in the pub folder. However, Magento is still generating image and asset URLs with pub in the URL


instead of


This is happening for images, javascript, and css file.

The obvious question: Why is this happening, how can I fix it.

The less obvious question: Where does the PHP logic reside for adding pub to asset URL so I can debug this myself.

Cache had been cleared with a

rm -rf var/generation/*
rm -rf var/cache/*

1 Answer 1


Turns out the caches weren't entirely cleared. The system was running with the default full page caching enabled, and I had failed to clear the var/page_cache folder.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.