0

I'm running an https magento site on a nginx server. I'd like to serve my static content from a cdn (Amazon Cloudfront).

I can do this easily by changing the media/css/js urls from

www.mysite.com/xxx to cdn.mysite.com/xxx

however older browsers & operating systems (XP for example) don't support the SNI that makes this possible.

So, my question is:

How can I set my media/css/js base urls to be (www.mysite.com/xxx) when I detect that a user is running XP (for example), but leave them as cdn.mysite.com/xxx by default

I'd prefer not to have to set up multiple stores, just to be able to change these variables without the user knowing anything about it.

1

I don't think there is going to be a nice clean solution here without using multiple stores to be honest but an option, not a great option is to rewrite Mage_Core_Model_Store and alter what is returned by the getBaseUrl() method according to browser?

  • Thanks Jonathan, do you think the 'clean' way to solve this would be to use multiple stores? – collend Oct 17 '14 at 8:40
  • I just don't like to rewrite such a fundamental class as Mage_Core_Model_Store so for me, if it can be achieved by not doing this then that is going to be the better solution. – Jonathan Hussey Oct 17 '14 at 9:51
0

We implemented a server side change of skin, template & layout using controller_action_predispatch event:

$urlModel = Mage::getModel('core/url');
/* @var $urlModel Mage_Core_Model_Url */
$store = Mage::app()->getStore();
/* @var $store Mage_Core_Model_Store */
$code  = $store->getCode();
if (1 == 1) {
    $config = Mage::getConfig();
    /* @var $config Mage_Core_Model_Config */
    $config->setNode('stores/'.$code.'/design/theme/template', 'iphonetheme', true);
    $config->setNode('stores/'.$code.'/design/theme/skin', 'iphonetheme', true);
    $config->setNode('stores/'.$code.'/design/theme/layout', 'iphonetheme', true);
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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