Magento : Get Base Url , Skin Url , Media Url , Js Url , Store Url and Current Url

Get Url in phtml files

1. Get Base Url :


2. Get Skin Url :


(a) Unsecure Skin Url :


(b) Secure Skin Url :

$this->getSkinUrl('images/imagename.gif', array('_secure'=>true));

3. Get Media Url :


4. Get Js Url :


5. Get Store Url :


6. Get Current Url


Get Url in cms pages or static blocks

1. Get Base Url :

{{store url=""}}

2. Get Skin Url :

{{skin url='images/imagename.jpg'}}

3. Get Media Url :

{{media url='/imagename.jpg'}}

4. Get Store Url :

{{store url='mypage.html'}}
Tags:  ,


shajar 25-06-2012, 15:49

Good help for begginners

Pawel 18-01-2013, 18:56

Hi. Do You know how o get secure url in CMS Pages/Static Blocks?

Jagdeep Banga 06-05-2013, 10:36

Hi Pawl,

Try {{secure_base_url}} in CMS Pages/Static blocks.

Trabant 20-01-2013, 05:08

Thank! Helped me a LOT as new user. Why? I installed Magento on a VPS (managed) WITHOUT a domainname. Just the IP/path to get there. Succesfully installed Magento. The domainname is going to be redirected later through DNS.
But afer adding (succesfully) a second store with another parked domain I could not get it work with its own theme :-( Searched for hours….
As many tuto’s say that you only have to change the Base URL under Config -> General -> Web this did not work for me.
After I read about the code above I finaly found out tha the base url was different from the Base Skin/Media?JavaScipt URL.
So in this case I had to set the Base URL to the actual domain eg. “” and for others I hade to use the path to my server eg. ””
Just had to leave Base Link URL to {{unsecure_base_url}}

Now it all works just fine! Two stores, two domains, two catalogues and finaly also two themes :-)


Tapan Kumer Das 17-03-2013, 03:18

Thanks a lot. You save my lot of time. This cheat sheet is bookmarked for later use.

clear 02-04-2013, 09:40

I am genuinely delighted to read this web site posts which
contains tons of helpful facts, thanks for providing these kinds of

Danson 23-07-2013, 01:43

Very good post, clear and easy to follow

MagePsycho 13-08-2013, 14:04

$currentUrl = Mage::helper(‘core/url’)->getCurrentUrl()

$currentUrl = Mage::getUrl(‘*/*/*’, array(‘_current’ => true));
above code may not work always as expected.
Better way to find the current url is to use the following code:

if (!in_array(Mage::app()->getFrontController()->getAction()->getFullActionName(), array(‘cms_index_noRoute’, ‘cms_index_defaultNoRoute’))) {
$currentUrl = Mage::helper(‘core/url’)->getCurrentUrl();

Matt 28-05-2014, 20:42

Great reference for the days my brain isnt switched on to quickly grab magento url ref’s.


Leave a Reply

− four = one

Warning: Invalid argument supplied for foreach() in /home/jagdeepb/public_html/wp-content/plugins/gantry/core/gantrygzipper.class.php on line 145

Warning: Invalid argument supplied for foreach() in /home/jagdeepb/public_html/wp-content/plugins/gantry/core/gantrygzipper.class.php on line 151