Magento: Get current page url

Hello friends,

Before few days, while working with magento, we have a requirement to get current page url.

To fulfill our requirement we have searched the web and got proper solution.

And to get current page url we have used under given code:


Same as above code, we can use under given magento code lines to get base url of magento installation, to get url of media directory, to get url of skin directory and to get url of js directory respectively.


Hope this will help you.

Posted in Magento. 1 Comment »

One Response to “Magento: Get current page url”

  1. Magento Developer (@magepsycho) Says:

    $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();

Speak Your Mind

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

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

Google photo

You are commenting using your Google 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 )

Connecting to %s

%d bloggers like this: