Redirect to referring page after form submission Trying to figure out how to redirect a user back to referring page after they have completed our feedback form. So a scenario would be if im on page foo/bar and I click on feedback webform link on that page. I then proceed to fill out the webform and then hit submit I will then be directed back to foo/bar page with confirmation message displayed at top of page. Webform module does give me an option to add in a custom confirmation URL and also the ability to add in tokens. However I have had no success with current tokens as none of them redirect me back to referring page. 



Would creating a custom token maybe help with resolving this issue or hook_form_alter? Kind of stuck on how best to approach this.
You can't rely on the referrer header, because clients can refuse to provide one. For this use case Drupal has implemented a query parameter destination. Configure the webform with a default Confirmation URL, like &lt;front&gt;, and then add the current url as destination query string to links pointing at the webform.

For example add a feedback link to nodes:

use Drupal\Core\Url;

/**
 * Implements hook_preprocess_HOOK() for node templates.
 */
function mymodule_preprocess_node(&amp;$variables) {
  $variables['content']['feedback'] = [
    '#type' =&gt; 'link',
    '#title' =&gt; t('Feedback'),
    '#url' =&gt; new Url(
      'entity.webform.canonical',
      ['webform' =&gt; 'feedback'],
      ['query' =&gt; ['destination' =&gt; Url::fromRoute('&lt;current&gt;')-&gt;toString()]]
    ),
    '#cache' =&gt; ['contexts' =&gt; ['url.path']],
  ];
}


This overrides the configured confirmation URL and returns to the referring page after the webform is submitted.

In a page template you don't need the cache context and you can use this Twig only solution, as @PaulH has suggested:

href="/form/feedback?destination={{ path('&lt;current&gt;') }}"