How to redirect a customer to another URL using a controller

<?php
namespace Dfe\Facebook\Controller\Index;
class Index extends \Magento\Framework\App\Action\Action {
	/**
	 * @override
	 * @see \Magento\Framework\App\Action\Action::execute()
	 * @return \Magento\Framework\Controller\Result\Redirect
	 */
	public function execute() {
		return $this->resultRedirectFactory->create()->setUrl(rm_request('url'));
	}
}

Another example from the core:

An example with setPath:

Can you redirect in Model or Observer? I need use it in Observer. How can do that?

How to redirect a visitor in an observer?

See also:

<?php namespace ???????\????????\Observer; use Magento\Framework\Event\ObserverInterface; class Urlredirect implements ObserverInterface { protected $resultRedirectFactory; protected $_response; public function __construct( \Magento\Framework\App\ResponseInterface $response, \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig ) { $this->scopeConfig = $scopeConfig; $this->_response = $response; } public function execute(\Magento\Framework\Event\Observer $observer) { $request = $observer->getEvent()->getControllerAction()->getRequest(); $redirecturl = $this->scopeConfig->getValue('web/redirect/redirect_url', \Magento\Store\Model\ScopeInterface::SCOPE_STORE); $activornot = $this->scopeConfig->getValue('web/redirect/active', \Magento\Store\Model\ScopeInterface::SCOPE_STORE); if ($activornot == 1 && $request->getFullActionName() == 'cms_index_index') { $this->_response->setRedirect($redirecturl); } } }