title: cakephp 3.x routing to subfolders
body: <p>On my website I have the usual routes for</p>
  
  <pre><code>website.com
  website.com/pages/about
  website.com/img/116633
  ...
  </code></pre>
  
  <p>Now I have these pages</p>
  
  <pre><code>website.com/username/mike
  website.com/username/john
  website.com/username/eric
  ...
  </code></pre>
  
  <p>which should become</p>
  
  <pre><code>website.com/mike
  website.com/john
  website.com/eric
  ...
  </code></pre>
  
  <p>my routing goes like this:</p>
  
  <pre><code>$routes-&gt;connect(
      '/*',
      ['controller' =&gt; 'username', 'action' =&gt; 'index'],
      ['routeClass' =&gt; 'DashedRoute']
  );
  </code></pre>
  
  <p>And this works, but all other pages like</p>
  
  <pre><code>website.com/pages/about
  website.com/img/116633
  </code></pre>
  
  <p>are broken (they take the 'controller' => 'username')</p>
  
  <p>what is the best way to make this happen?</p>
  
  <p>Below my full routes.php</p>
  
  <pre><code>    Router::defaultRouteClass('Route');
  
  Router::extensions(['html', 'rss', 'pdf']);
  
  Router::scope('/', function ($routes) {
  
      $routes-&gt;connect('/', ['controller' =&gt; 'Search', 'action' =&gt; 'start']);
  
      $routes-&gt;connect('/start', ['controller' =&gt; 'Search', 'action' =&gt; 'start']);
  
      $routes-&gt;connect(
          '/*',
          ['controller' =&gt; 'username', 'action' =&gt; 'index'],
          ['routeClass' =&gt; 'DashedRoute']
      );
  
      $routes-&gt;fallbacks('InflectedRoute');
  });
  
  
  
  
  Router::connect('/img/*', ['controller' =&gt; 'Pic', 'action' =&gt; 'item']);
  
  Router::url([
      'controller' =&gt; 'Pages',
      'action' =&gt; 'lang',
      '_base' =&gt; 'false'
  ]);
  
  
  
  Router::addUrlFilter(function ($params, $request) {
      if (isset($request-&gt;params['lang']) &amp;&amp; !isset($params['lang'])) {
          $params['lang'] = $request-&gt;params['lang'];
      }
      return $params;
  });
  
  
  Plugin::routes();
  </code></pre>