Magento: Get current Url of the page
The following code gives you the current url of the page you are:-
$currentUrl = $this->helper('core/url')->getCurrentUrl();
// Gives the base url of your magento installation
$baseUrl = Mage::getBaseUrl();
// Gives the url of media directory inside your magento installation
$mediaUrl = Mage::getBaseUrl('media');
Another way to get current url
$urlRequest = Mage::app()->getFrontController()->getRequest();
$urlPart = $urlRequest->getServer('ORIG_PATH_INFO');
if(is_null($urlPart))
{
$urlPart = $urlRequest->getServer('PATH_INFO');
}
$urlPart = substr($urlPart, 1 );
$currentUrl = $this->getUrl($urlPart);
Related posts:
- Magento: How to check if current page is homepage?
- Magento: Easily add breadcrumbs to any page
- Magento: Convert Price from Current Currency to Base Currency and vice-versa
- Magento: Get current and parent category
- Magento: Resize Image
- Magento: Get width height of image using Varien_Image class
- Magento: Create CMS Page & Static Block programmatically
- Magento: Solution to “Error: 404 Not Found” in Admin Login Page
- Magento: Custom function to resize image proportionally
- Javascript: How to get current URL without Query string?

Pingback: Magento – Alcune variabili molto utili relative all’URL | Bisonte_biscottato
Pingback: Get Media Url, Get Current Url, Get Skin Url, Get JS Url, Get Store Url , Get Base Url in Magneto | DiezArticles