How to (truly) alter a URL in Drupal 8 I'm using OutboundPathProcessorInterface. I notice a few odd things about its behavior.


In adding, for example, "/x" to the path, it works in some cases, like admin/structure, but not others, like admin/content or the path I'm interested in, which is defined in a view. This is despite my setting the module's weight to 999 in its install file (before installing), so presumably no other module would be altering the path downstream.
Where it does work, such as admin/structure, the page with the original path loads, with the original URL in the address bar, but all menu links have the altered path.
When I watch it in xdebug, AFTER I alter the path with the query string in $options the URL comes through the function again, with the path set to the original value.
The module weight won't do anything here. You set the priority in the service tag.
You have to look what other path processors do at which priority to find the right place for your custom code. And use an inbound path processor to remove the x you have added outbound.
The outbound processor is called multiple times while building a page, because you usually have more than one link on the site (and not all are visible).
(question in comments) You can do this, outbound transfer query parameters to the path and inbound transfer parts of the path again back to the query parameters. Internally Drupal sees only the short base path with query parameters, externally you see the full path without query parameters. An example for inbound is PathProcessorFiles::processInbound