Magento – get directory paths, get Base URLs, get URLs in static block, get secure URL

This post help you to get url, directory path, to get module URL. This is very basic post, that will help to beginners.

Get Base URL

 Mage::getBaseUrl() => Get base url path e.g.
 Mage::getBaseUrl('media') => Get MEDIA folder path e.g.
 Mage::getBaseUrl('js') => Get JS folder path e.g.
 Mage::getBaseUrl('skin') => Get SKIN folder path e.g.

Get Current URL


Get Home URL


Create module your


Get secure URL
To get secure URL you just need to add one more parameter as bellow,


Get Directory paths

 //output : /var/www/html/magento
 //output : /var/www/html/magento/app
 //output : /var/www/html/magento/media

Same way you can get more directory path,
Mage::getBaseDir(‘design’) => Get design directory path
Mage::getBaseDir(‘code’) => Gives code directory file path
Mage::getBaseDir(‘lib’) => Gives lib directory file path
Mage::getBaseDir(‘skin’) => Gives skin directory file path
Mage::getBaseDir(‘var’) => Gives var directory file path
Mage::getBaseDir(‘cache’) => Gives cache directory file path
Mage::getBaseDir(‘log’) => Gives log directory file path

Get URL path in Static Block
Get Base URL

{{base url=''}}

Get Skin URL

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

Get Media URL

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

Get Store URL

{{store url=''}}

12 thoughts on “Magento – get directory paths, get Base URLs, get URLs in static block, get secure URL

  1. Pingback: Magento – CMS Page URL | Tech Bandhu

  2. Pingback: Magento – get CMS Page URL | Tech Bandhu

  3. Just a note on how to find the current url:
    $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();

    • Hello Helio, You mean admin URL? Here is the code,

      $route = '*/customer/index/';
      Mage::helper('adminhtml')->getUrl($route, $params);
      $this->getUrl('adminhtml/system_config/edit', array('section'=>'web', 'store'=>$code));
      $this->getUrl('adminhtml/customer/edit', array('id'=>1));

      I will also update this to post soon….

  4. How can I get this form to post results ONLY to SECURE URL?

    <form id="search_mini_form" action="getPageUrl( searchresults ) ?>” method=”get”>

  5. Pingback: Magenta problems and solutions | Allah is the one and only

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s