Dynamic Entry URI's for pages
Not sure I'm following 100%, but in Craft 2, a structured section has a "Nested Entries" text box in the "Entry URL Format" under a section's settings where you can dynamically access the URI of a parent element in a structure like so:

{parent.uri}/{slug}


In Craft 3, under a section's Settings, that has moved to "Site Settings" and you just have the "Entry URL Format" text box.  You could do something similar like so:

{parent.uri ?? ''}/{slug}


i.e. if there isn't a parent.uri, just use the slug, otherwise use prepend it.

You've got the full power of Twig in those text boxes, so you can adjust however you need.