0

how to redirect the custom controller path to specific store name

http://testurl.com/testmodule/index/testview/id/123/

to

http://testurl.com/testname

thanks

2 Answers 2

1

You can try below code in your controller to set the redirect to your custom URL.

Mage::app()->getResponse()->setRedirect($url)->sendResponse(); // or Mage::app()->getFrontController()->getResponse()->setRedirect($url)->sendResponse(); 

Edit:

$this->loadLayout(); $this->getLayout()->getBlock('block_class')->setTemplate('template_file_path')); // Do your process $this->renderLayout(); 

Reference: Can you set a template for every action within a controller?

Hope it helps!!!

8
  • thanks it is redirecting but page is not loading with that id Commented Sep 10, 2019 at 7:33
  • Have you tried $this->_redirect($url); in your controller? Also Mage::app()->getResponse()->setRedirct($url); Commented Sep 10, 2019 at 7:37
  • no actually i am doing in controller like testurl.com/testmodule/index/testview/id/123 in test view funtion i am setting a template and loading page with current url id parameter Commented Sep 10, 2019 at 7:42
  • 1
    yes i have tried this, along with this i have added Router concept, this is working well now, thanks Commented Sep 16, 2019 at 6:24
  • 1
    no for my scenario this is ok Commented Sep 16, 2019 at 6:30
1

In the controller action you need to write this line to redirect with current parameter (redirect inside your domain, not to an external website)

$this->_redirect('testname/index/index', $this->getRequest()->getParams()); 

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.