Get Referer Url in Magento 2.

Magento 2, Get Referer url by calling function getRefererUrl() or getRedirectUrl() from RedirectInterface Object.

Magento core Interface, Magento\Framework\App\Response\RedirectInterface used for fetch Referer URL.

In PHP you can call simply by, $_SERVER[“HTTP_REFERER”], In Magento 2 Best Practice, you need to call RedirectInterface in your __construct() function and get referrer URL.

Call below the line in your function,

echo $this->redirect->getRefererUrl();
echo $this->redirect->getRedirectUrl();

Using this way, You can get your referer url