×

Welcome to TagMyCode

Please login or create account to add a snippet.
0
0
 
0
Language: Text
Posted by: bejoy balan
Added: Oct 30, 2017 6:23 AM
Views: 6
Tags: magento url
Get alias url and redirect magento
  1. if($this->getRequest()->isSecure()) {
  2.             $requestUri = $this->getRequest()->getRequestUri();
  3.             $requestUri = explode('?', $requestUri);
  4.             if(isset($requestUri[1])) {
  5.                 $requestUri = $requestUri[1];
  6.             } else {
  7.                 $requestUri = '';
  8.             }
  9.             if ($alias = $this->getRequest()->getAlias(Mage_Core_Model_Url_Rewrite::REWRITE_REQUEST_PATH_ALIAS)) {
  10.                 $url = Mage::getBaseUrl('link', false).ltrim($alias, '/');
  11.             } else {
  12.                 $url = Mage::getBaseUrl('link', false).ltrim($this->getRequest()->getPathInfo(), '/');
  13.             }
  14.             if(!empty($requestUri)) {
  15.                 $url .= '?' . $requestUri;
  16.             }
  17.             $this->getResponse()
  18.                 ->setRedirect($url)
  19.                 ->sendResponse();
  20.             exit;
  21.         }