How do I modify the query parameters? I want to modify query parameters used when accessing a Drupal page. I tried implementing hook_url_inbound_alter(), but it only allows to parse/modify the path, and it doesn't allow any interaction with the query string.

I see there is also drupal_get_query_parameters(), which allows to read the query parameters.

I could detect the presence of a query value in index.php and do a string replacement on the value if needed, but I don't want to pollute the front controller.

Do you have any better advice?
1) you need to implement EventSubscriber, use KernelEvents::REQUEST in getSubscribedEvents() method

2) then you use \Drupal::request()-&gt;query-&gt;set('key', 'value');