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

This post will help you to get base url, skin url, media url, js url, store url and current url in Magento. This is very basic post, that will help to beginners.

Get Url in PHTML Files

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. http:/
Mage::getBaseUrl('skin') // Get SKIN folder path e.g.

Get Current Url:


Get Home Url:


Create Your Module Url:


Get Secure Url:
To get secure url you just need to add one more parameter as below,

Mage::getUrl('', array( '_secure' => true ))
Mage::getUrl( 'module/controller/action' , array( '_secure' => true ))

Get Skin Url:


(a) Get Unsecure Skin Url:


(b) Get Secure Skin Url:

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

Get Media Url:


Get Js Url:


Get Store Url:


Get Directory Paths:

Mage::getBaseDir() // output : /var/www/html/magento
Mage::getBaseDir('app') // output : /var/www/html/magento/app
Mage::getBaseDir('media') // 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 in CMS Pages or Static Blocks

Get Base Url:

{{store url=""}}

Get Skin Url:

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

Get Media Url:

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

Get Store Url:

{{store url='mypage.html'}}

Hope this helps.

One Comment on “Magento: Get Base Url, Skin Url, Media Url, Js Url, Store Url and Current Url”

Leave a Reply

Your email address will not be published. Required fields are marked *