Magento – How to get Magento root url properly

base-urlgeturlurl

I have custom script located inside Magento root directory used for ajax call. I am wondering what would be the safest way to get proper root url, no matter which store is user currently at.

Will Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB) always show root url without index.php or store code or anything else inside url?

I made some testing and it looked fine, but maybe I missed something that will show up on one of the 1000 different stores where this will be used. This is why I am asking this question.

Tnx!

Best Answer

This should get you what you need:

Mage::getUrl('');
Related Topic