title: zf2 root url static and dynamic
body: <p>I currently am using static routes, but I was wondering if you can have static and dynamic routes together. So I am using this:</p>
  
  <pre><code>    'contact' =&gt; array(
          'type' =&gt; 'literal',
          'options' =&gt; array(
              'route'    =&gt; '/contact',
              'defaults' =&gt; array(
                  'controller' =&gt; 'Application\Controller\IndexController',
                  'action'     =&gt; 'contact',
              ),
          ),
      ),
  </code></pre>
  
  <p>and I would like to use something like this alongside that</p>
  
  <pre><code>    'contact' =&gt; array(
          'type' =&gt; 'segment',
          'options' =&gt; array(
              'route'    =&gt; '/:curated_url',
              'defaults' =&gt; array(
                  'controller' =&gt; 'Application\Controller\IndexController',
                  'action'     =&gt; 'curated',
              ),
          ),
      ),
  </code></pre>
  
  <p>The dynamic route will accept everything though and hijack the static routes. So then I was looking at using the actions routing, but that <code>curated_url</code> could be anything.</p>
  
  <p>Is there any way to possibly use the dynamic one and have defaults where if it is not in there then it will look in the database to see if it is in there?</p>
  
  <p>********** EDIT **********</p>
  
  <p>So here is what I spun up for the time being and it works but I know there is a better way, I just don't know that better way.</p>
  
  <p>router.config.php</p>
  
  <pre><code>'curated-url' =&gt; array(
      'type' =&gt; 'Zend\Mvc\Router\Http\Segment',
      'options' =&gt; array(
          'route'    =&gt; '/:url',
          'defaults' =&gt; array(
              'controller' =&gt; 'Application\Controller\IndexController',
              'action'     =&gt; 'custom',
          ),
      ),
  ),
  </code></pre>
  
  <p>IndexController.php</p>
  
  <pre><code>/*
   * Special kind of special
   */
  public function customAction()
  {
      $params = array();
      $type = $this-&gt;params('url');
  
      if ('contact' == $type) {
          $params = $this-&gt;contactAction($this-&gt;getRequest());
      } else if ('discover' == $type) {
          $params = $this-&gt;discoverAction();
      } else if ('how-it-works' == $type) {
          $params = $this-&gt;howItWorksAction();
      } else if ('privacy-policy' == $type) {
          $params = $this-&gt;privacyPolicyAction();
      } else if ('questions' == $type) {
          $params = $this-&gt;questionsAction();
      } else if ('terms-of-use' == $type) {
          $params = $this-&gt;termsOfUseAction();
      } else if ('volunteer' == $type) {
          $params = $this-&gt;volunteerAction();
      } else {
          $params = $this-&gt;curatedAction($type);
          $type = 'curated';
      }
  
      $view = new ViewModel($params);
      $view-&gt;setTemplate('application/index/' . $type);
  
      return $view;
  }
  </code></pre>