<p dir="auto"><strong>Symfony version(s) affected</strong>: 4.3</p>
<p dir="auto"><strong>Description</strong><br>
URL parsing fails. For example:<br>
<code class="notranslate">https://nova.laravel.com/password/reset</code><br>
This resolves correctly.<br>
However <code class="notranslate">https://nova.laravel.com//password/reset</code> this results in a 404. Which could be seen as a user error.<br>
But <code class="notranslate">https://nova.laravel.com//foobar/password/reset</code> also resolves, however incorrectly. Clearly signaling it as a bug.</p>
<p dir="auto"><strong>How to reproduce</strong><br>
Go to <code class="notranslate">https://nova.laravel.com//foobar/password/reset</code>. Or in any Laravel/Symfony project add an extra <code class="notranslate">/</code> after the host.</p>
<p dir="auto"><strong>Possible Solution</strong><br>
I added a possible solution in this PR.<br>
<a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="391730932" data-permission-text="Title is private" data-url="https://github.com/symfony/symfony/issues/29631" data-hovercard-type="pull_request" data-hovercard-url="/symfony/symfony/pull/29631/hovercard" href="https://github.com/symfony/symfony/pull/29631">#29631</a></p>
<table role="table">
<thead>
<tr>
<th>Q</th>
<th>A</th>
</tr>
</thead>
<tbody>
<tr>
<td>Bug report?</td>
<td>no</td>
</tr>
<tr>
<td>Feature request?</td>
<td>yes?</td>
</tr>
<tr>
<td>BC Break report?</td>
<td>no</td>
</tr>
<tr>
<td>RFC?</td>
<td>no</td>
</tr>
<tr>
<td>Symfony version</td>
<td>all</td>
</tr>
</tbody>
</table>
<p dir="auto">I am working on application which define different route parameters depending on subdomain (for simplicity lets call them languages)</p>
<p dir="auto">For example there are <code class="notranslate">en</code>, <code class="notranslate">pl</code>, <code class="notranslate">gb</code> sub domains. Which may override some global routes (defined in domain routing)</p>
<div class="highlight highlight-source-yaml notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="#routing.yml
_domain:
    resource: routing_domain.yml

_subdomain:
    resource: routing_subdomain.yml"><pre class="notranslate"><span class="pl-c"><span class="pl-c">#</span>routing.yml</span>
<span class="pl-ent">_domain</span>:
    <span class="pl-ent">resource</span>: <span class="pl-s">routing_domain.yml</span>

<span class="pl-ent">_subdomain</span>:
    <span class="pl-ent">resource</span>: <span class="pl-s">routing_subdomain.yml</span></pre></div>
<div class="highlight highlight-source-yaml notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="#routing_domain.yml
app_default_index:
    path:     /{language}/index
    defaults: { _controller: AppBundle:Default:index }
    methods: ['GET']
    requirements:
        language: 'en'

app_default_catch_all:
    path:     /{language}/{slug}
    defaults: { _controller: AppBundle:Default:catchAll }
    methods: ['GET']
"><pre class="notranslate"><span class="pl-c"><span class="pl-c">#</span>routing_domain.yml</span>
<span class="pl-ent">app_default_index</span>:
    <span class="pl-ent">path</span>:     <span class="pl-s">/{language}/index</span>
    <span class="pl-ent">defaults</span>: <span class="pl-s">{ _controller: AppBundle:Default:index }</span>
    <span class="pl-ent">methods</span>: <span class="pl-s">['GET']</span>
    <span class="pl-ent">requirements</span>:
        <span class="pl-ent">language</span>: <span class="pl-s"><span class="pl-pds">'</span>en<span class="pl-pds">'</span></span>

<span class="pl-ent">app_default_catch_all</span>:
    <span class="pl-ent">path</span>:     <span class="pl-s">/{language}/{slug}</span>
    <span class="pl-ent">defaults</span>: <span class="pl-s">{ _controller: AppBundle:Default:catchAll }</span>
    <span class="pl-ent">methods</span>: <span class="pl-s">['GET']</span>
</pre></div>
<div class="highlight highlight-source-yaml notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="#routing_subdomain.yml
app_default_index:
    path:     /{language}/index
    defaults: { _controller: AppBundle:Default:index }
    methods: ['GET']
    requirements:
        language: 'en|gb'
"><pre class="notranslate"><span class="pl-c"><span class="pl-c">#</span>routing_subdomain.yml</span>
<span class="pl-ent">app_default_index</span>:
    <span class="pl-ent">path</span>:     <span class="pl-s">/{language}/index</span>
    <span class="pl-ent">defaults</span>: <span class="pl-s">{ _controller: AppBundle:Default:index }</span>
    <span class="pl-ent">methods</span>: <span class="pl-s">['GET']</span>
    <span class="pl-ent">requirements</span>:
        <span class="pl-ent">language</span>: <span class="pl-s"><span class="pl-pds">'</span>en|gb<span class="pl-pds">'</span></span>
</pre></div>
<p dir="auto">Because of priority of sub domain routes  it has to be imported last (To override <code class="notranslate">app_default_index</code> from  <code class="notranslate">routing_domain.yaml</code>)</p>
<p dir="auto">Problem with this approach is that it puts <code class="notranslate">app_default_index</code> on the bottom of routes priority, causing that <code class="notranslate">app_default_catch_all</code> is before <code class="notranslate">app_default_index</code>.</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content=" ----------------------- -------- -------- ------ -------------------- 
  Name                    Method   Scheme   Host   Path                
 ----------------------- -------- -------- ------ -------------------- 
  app_default_catch_all   GET      ANY      ANY    /{language}/{slug}  
  app_default_index       GET      ANY      ANY    /{language}/index   
 ----------------------- -------- -------- ------ -------------------- "><pre class="notranslate"><code class="notranslate"> ----------------------- -------- -------- ------ -------------------- 
  Name                    Method   Scheme   Host   Path                
 ----------------------- -------- -------- ------ -------------------- 
  app_default_catch_all   GET      ANY      ANY    /{language}/{slug}  
  app_default_index       GET      ANY      ANY    /{language}/index   
 ----------------------- -------- -------- ------ -------------------- 
</code></pre></div>
<p dir="auto">It there any way that I am able to override <code class="notranslate">app_default_index</code> route, but keep its initial position?<br>
I've found an place where this logic is set <code class="notranslate">https://github.com/symfony/symfony/blob/master/src/Symfony/Component/Routing/RouteCollection.php#L125</code></p>
<blockquote>
<p dir="auto">// we need to remove all routes with the same names first because just replacing them<br>
// would not place the new route at the end of the merged array.</p>
</blockquote>
<p dir="auto">What is an reason that route should be put on end of array?  How can I solve this problem, without using dynamic route loader and keep everything as simple as possible?</p>