Redirecting to external or internal URL from within a Magento controller

Submitted by metaharper - 6 years ago

While developing an extension, I came across the need to redirect the user away from the admin panel to an external URL/route . I learned that Magento had options for redirecting depending on whether or not the URL was based internally or externally. The issue I experienced is that my external URLs were prefixed with Magento's base URL. See the below code for both methods:

// To redirect to external URL and avoid having your base URL prepended to each link:


$url = "";

// To redirect to internal URL/route:

$path = "module/controller/action/param1/param1value";
Learn PHP
comments powered by Disqus
Proudly hosted on Digital Ocean