Query for entry related to current entry in section URI settings
Your will need to set up a route for the entry1 section.

For example, if your entry1 uri is looke like entry1section/{slug}, and your template is like "_entry1section/index" then the route would be

entry1section/{slug}/* to "_entry1section/index"

Then in the template, using 

{% set lastSegment = craft.request.getLastSegment() %}
{% set all_slug_in_entry1_section = someFunctionToRetrieveSlug() %}
{% set all_slug_in_entry2_section = someFunctionToRetrieveSlug() %}

{% if lastSegment in all_slug_in_entry1_section %}

  {# means your request url is {siteUrl}entry1section/{slug} #}
  {# display the content from entry1 #}

{% elseif lastSegment in all_slug_in_entry2_section %}

  {# means your request url is {siteUrl}entry1section/{entry1-slug}/{entry2-slug} #}
  {# display the content from entry2 #}

{% else %}

  {% redirect '404.html' %}

{% endif %}