5

I want to redirect my site to home page (base URL) in Controller.

$this->_redirect();

Using above mentioned function gives me the warning to specify the argument.

Warning: Missing argument 1 for Mage_Core_Controller_Varien_Action::_redirect()

When I use the following as argument

$this->_redirect(Mage::getBaseUrl());

It just append the base url in my site url which results something like this

Which is obviously a 404 page. Please help me to figure this out.

3 Answers 3

13

I reckon you should try to the following:

$this->_redirect("/");
2
  • Thanks a lot. Brilliant.. you are right, digging more into "Mage_Core_Controller_Varien" and got the result. protected function _redirect($path, $arguments = array()) Commented May 12, 2016 at 9:04
  • @MuhammadSaiid feel free to mark your question as answered so it'll benefits for others ;) Commented May 12, 2016 at 9:05
6

You can try below code

$url = Mage::getBaseUrl();
Mage::app()->getFrontController()->getResponse()->setRedirect($url);
1
  • Yes, it worked. Thanks for let me know another way to cop this out. :) Commented May 12, 2016 at 9:16
-2
$this->_redirectUrl('/magento');

Where "magento" is my root folder name. (For localhost/magento..)

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.