2

In a new site, with multiple domains, I have a problem. First the several websites with their own store view:

shop.mydomain.org, code shop
retail.mydomain.org, code retail
*.mydomain.org, code base

The base_url for all these stores is set to {{base_url}} since the last one is dynamic. In a .htaccess file, the code is set, ie:

RewriteCond %{HTTP_HOST} ^shop.mydomain.*$
RewriteRule ^ - [E=MAGE_RUN_TYPE:website,E=MAGE_RUN_CODE:shop] [L]

When visiting ie shop.mydomain.org the first time after clearing the cache, everything works fine. The base_url is set to shop.mydomain.org. Without clearing the cache and continueing on shop.mydomain.org, the base_url is still okay.

Still without clearing the cache, when I visit retail.mydomain.org, there is a problem with the base_url. On this domain, the base_url is the same as for shop.mydomain.org, when I would expect it to change to retail.mydomain.org.

I know I can change the base_url in the configuration to shop.mydomain.org and retail.mydomain.org solving my problem for these 2 domains. But, the last domain (*.mydomain.org), can't be set to a specific base_url. All must work with a template in which an image is loaded based on the * part in the domain.

What I've tried:

In Mage_Core_Model_Store->getBaseUrl(), change line

$this->_baseUrlCache[$cacheKey] = rtrim($url, '/') . '/';

to

return rtrim($url, '/') . '/';

to prevent Magento from adding the url in cache.

And more or less the same in Mage_Core_Model_Website::getConfig(); don't store the config value in cache if the path contains 'url'.

Both options didn't work. Does someone have a solution?

1 Answer 1

1

You shouldn't use {{base_url}} as value for base url. It can lead to security issues.
Edit the configuration for each website from System->Configuration->Web and set the base url accordingly: http://shop.mydomain.org/, http://retail.mydomain.org/ and http://mydomain.org/.
Clear the cache and give it a go.
I don't think you need the last one to be dynamic. Or maybe I'm missing something.
If you insist on working with different URLs (dynamic) for one website, I think you will have a problem. For example most block cache files depend on the store id (for example the main menu), and if the cache is created with one URL when accessing with a different url you will get the cached data with the first URL.
Maybe you should rethink your business logic here.

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.