magento 2 redirect url

<?php
namespace VendorName\ModuleName\Controller\Index;

class Index extends \Magento\Framework\App\Action\Action {

    /**
     *
     * @return \Magento\Framework\Controller\Result\Redirect
     */
    public function execute() {

        $url = 'http://hellomagento2.com';
        // internal
        // return $this->resultRedirectFactory->create()->setPath('*/*/');
        // external
        return $this->resultRedirectFactory->create()->setUrl($url);
    }
}

发表评论

电子邮件地址不会被公开。 必填项已用*标注