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!!!

9
  • thanks it is redirecting but page is not loading with that id
    – Raghu
    Commented Sep 10, 2019 at 7:33
  • Have you tried $this->_redirect($url); in your controller? Also Mage::app()->getResponse()->setRedirct($url);
    – Sumit
    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
    – Raghu
    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
    – Raghu
    Commented Sep 16, 2019 at 6:24
  • 1
    no for my scenario this is ok
    – Raghu
    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());

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.