Magento’s configuration includes a hard coded field for the base site URL. This often creates headaches when a user migrates a system to a new server/URL, but hasn’t updated the URL entries in the core_config_data
table. These headaches are compounded by
- The fact that the entries in
core_config_data
are cached by Magento - Most web browsers aggressively cache HTTP header based redirects
- If a user didn’t update
core_config_data
, there’s also a good chance they’re the sort of user who wouldn’t update their web server configuration
Whenever I’m facing a problem like this with a system, I like to hop to the following code point
#File: app/code/core/Mage/Core/Controller/Varien/Front.php
if (isset($uri['scheme']) && $uri['scheme'] != $request->getScheme()
|| isset($uri['host']) && $uri['host'] != $request->getHttpHost()
|| isset($uri['path']) && strpos($requestUri, $uri['path']) === false
) {
Mage::app()->getFrontController()->getResponse()
->setRedirect($baseUrl, $redirectCode)
->sendResponse();
exit;
}
This complicated conditional statement is where Magento performs a redirect if the request URL doesn’t match the base url. Some quick var_dump
/exit
debugging before the call to sendResponse
can be a nice sanity check.