This tutorial will show you how to get Base secure URL without index.php in PHP code. It ‘s just a simple methods but many programmers will need. Hope this will be a useful magento tips.
First of all, make sure you enabled index.php for some reason. Now we have a PHP file at Magento root directory, and we want to call Magento secure pages from this PHP file.
Let’s use one of these methods
Mage::getUrl
or
Mage:: getBaseUrl
or
Mage::getStoreConfig(Mage_Core_Model_Url::XML_PATH_SECURE_URL);
All of those automatically detect if the page is already secure when you do not specify it.
You can specify a store with the second parameter of getStoreConfig. It accepts an ID, a code (as set in admin) or a Mage_Core_Model_Store object, just use whatever you have available in your code.
In template file you can use this to show URL
{{config path="web/unsecure/base_url"}}
To me, I prefer to use Mage:: getBaseUrl since it ‘s more official method.
If you meet anything wrong then please check one of these issues:
- Use Web Server Rewrites => Yes
- Caching is disabled. Clear cache if needed.
- Home and category work properly
- Server/hosting magento work well let’s check the best magento hosting list.
References:
https://magento.stackexchange.com/questions/35717/how-to-get-base-secure-url-without-index-php
https://tofuandtomato.wordpress.com/2014/11/07/magento-how-to-get-base-secure-url-without-index-php/