title: How do I make a catchall route in Zend Framework 2
body: <p>I'm creating a CMS module for ZF2 and I'd like it to not have to include &quot;/page&quot; or somesuch in the url. So, for example, the url for the imprint page would be <a href="http://www.yourdomain.com/imprint" rel="nofollow noreferrer">http://www.yourdomain.com/imprint</a></p>
  <p>How would you suggest doing this? I've considered the following approaches, but I haven't been able to get any of them working just how I want:</p>
  <ol>
  <li><p>Have a catchall route that connects to my PageController and passes the url path as a parameter. The problem here is getting the catchall route to play nice with existing routes. And this also means that all pages that should be 404 errors will now be routed through the PageController, which then has to handle 404 pages if the page is not found in the database.</p>
  <p>or</p>
  </li>
  <li><p>Observe the event EVENT_DISPATCH_ERROR and recover from it if the page exists in the db. I can catch the event, but I have no idea how to recover from it and trigger the PageController.</p>
  <p>or</p>
  </li>
  <li><p>Any time a cms page title is created, updated or deleted, rebuild a cache of all cms routes. This seems like a clean solution, but I'm not sure how to proceed other than to build the cache as a php config file in the config/autoload directory.</p>
  </li>
  </ol>
  <p>I'll be grateful for any ideas on how to accomplish this. Ideally, the solution will be able to handle a CMS-powered homepage (/) as well.</p>