Do you want to know how to Drupal?

Let's Drupal

How to set a custom redirection after form submission Drupal 9?

To redirect a user after form submit to a custom URL. We need to implement custom submit function.

use Drupal\Core\Form\FormStateInterface;

 * Implements hook_form_FORM_ID_alter().
function mydoule_form_YOUR_FORM_ID_alter(&$form, FormStateInterface $form_state, $form_id) {
  // add custom function as submit handler.
  $form['#submit'][] = '_mymodule_custom_submit_handler';

  // Sometime forms doesn't into account '#submit' parameter. So, we have to set custom handler to the specific button of the form
  $form['actions']['submit']['#submit'][] = '_mymodule_custom_submit_handler';

 * Custom submit handler for your form form.
function _mymodule_custom_submit_handler($form, FormStateInterface $form_state) {
  // Set a custom redirect.

You will need to replace module name and put into install file of your module and also don't forget to replace form id.