Custom taxonomy link automatically removing query string and re-directing

WordPress uses the redirect_canonical function in order to ensure that URLs are properly following the current permalink structure: https://codex.wordpress.org/Function_Reference/redirect_canonical

The function is hooked to automatically run on the template_redirect filter. In order to remove it, you need to add the following snippet to your theme or plugin:

remove_filter( 'template_redirect', 'redirect_canonical' );

Keep in mind that this will allow a single page (in this case taxonomy index) to have multiple URLs, which is not good for SEO, because the following URLs will show the same content:

WordPress will also not handle http://localhost/?categoryname=apples+oranges automatically, since its base logic only works with a single taxonomy. The best way to approach this issue would be to use custom rewrite rules and to introduce a new rewrite/query tag, for example categories, instead of the default categoryname. This however, is a topic that cannot be explained quickly and requires some research first.