I need to get the exact URL when customer visit my site on first time,
It is based on following options

  1. base url that depends on default website,store and store view,
  2. store code to urls enabled or not.

I got the base URL by

$websites = Mage::getModel('core/website')->getCollection()->addFieldToFilter('is_default', 1);
$website = $websites->getFirstItem();
$websiteId = $website->getId();
$websiteCode = $website->getCode();
$baseUrl = Mage::getConfig()->getNode('web/unsecure/base_url', 'website', $websiteCode);

The URL will be appended with store code if store code to urls is enabled in admin.

how to check store code to urls enabled programmatically in magento?

1 Answer 1


You can check if the store codes are included in the URL like this:

$flag = Mage::getStoreConfigFlag('web/url/use_store');

$flag will be true or false depending on the store codes in URL are enabled or not.

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.