How to create an advanced route with query strings? I have a main structure as my navigation. 
Within this structure I have multiple image galleries. 
I want to make the image gallery's urls dynamic. 

If I define a gallery within the structure entry:
https://mysite.com/sport/gallery/  

The url of the images in the gallery (which is a channel) should be:
https://mysite.com/sport/gallery/mygallerySlug?type=gallery&amp;parent=parentEntryId

now I would like to have a route which catches all of the ?type=gallery entries and load the "gallery/_entry" template. 

It shouldn't matter how deep in the structure the ?type=gallery is. 

I don't seem to be able to do this within the CP, and I've never used advanced routing... 

Any help appreciated! 

EDIT:

Maybe I need to specify a little further: 

I have a structure called "pages" which acts as the main structure.
I have a channel that is called "galleries" where I can upload images and assign a category. 
In my main structure I can assign galleries from within a matrix block and choose a category. That way I can regroup multiple entries from the channel "galleries" in a structure entry. 

The urls of the galleries should be completely dynamic: 

https://mysite.com/sport/gallery holds multiple gallery entries where each of these galleries should have a url the following way:
https://mysite.com/sport/gallery/gallery1
https://mysite.com/sport/gallery/gallery2 ...

another gallery collection could be here: 
https://mysite.com/karting/galleries/ 
whith links like that: 
https://mysite.com/karting/galleries/gallery3
https://mysite.com/karting/galleries/gallery4
etc..

I know I could specify the entry url of one gallery the following way in the "galleries" section url settings: 

{{ craft.entries.id(65).locale('de').first.uri }}/{slug}
where the id is the id of e.g. https://mysite.com/sport/gallery/ structure entry. 

But that works only for one gallery.

I could create a route for "sport/gallery/*" and assign the "gallery/_entry" template to it. But that way I would have to create a route for every gallery, which is not completely obvious, nor intuitive on a editor's point of view. 

In fact this is almost a duplicate of this question:
dynamic urls for channel/structure that&#39;s linked to the main structure

Cheers
Stefan
You can do this completely in the template. Have the structure entries resolve to a route like gallery/_router and then inside that template you could use this code to include the template of your choice:

{% switch craft.app.request.getParam('type') %}

    {% case "gallery" %}

        {% include "gallery/_entry" %}    

    {% case "anotherParam" %}

        {% include "gallery/_anotherParam" %}

     {% default %}

        {% include "gallery/_default" %}   

{% endswitch %}