title: Laravel - CNAME + Subdomain Routing
body: <p>I have my routes set up as follows:</p>
  
  <pre><code>&lt;?php
  
  Route::group([
      'domain' =&gt; '{username}.u.'.env('APP_DOMAIN'),
  ], function () {
      Route::get('/', 'FrontendController@site');
  });
  
  Route::group([
      'domain' =&gt; env('APP_DOMAIN'),
  ], function () {
      // Regular site routes
  });
  
  Route::group([
      'domain' =&gt; '{domain}',
  ], function () {
      Route::get('/', 'FrontendController@domain');
  });
  </code></pre>
  
  <p>What I'm trying to achieve is allowing users to have their own sites, e.g. hello.u.domain.com, and for those sites to also be served through a custom domain that is CNAME'd to their subdomain. Using the routing above, the wildcard subdomain works perfectly fine. However the custom domain routing is never hit; whenever a custom domain that is CNAME'd to the subdomain is visited, the regular site routes are used.</p>
  
  <p><code>APP_DOMAIN</code> is not the same as the custom domain, and I have <code>$router-&gt;pattern('domain', '[a-z0-9.]+');</code> in my <code>RouteServiceProvider.php</code> to allow <code>{domain}</code> as a full domain name.</p>