title: Custom lithium routing scenario
body: <p>I've been tasked with rewriting an existing website with large pre-existing link catalog. For argument's sake, let's assume we can't do anything that would change the link catalog. Here's a few examples of the link structure we're working with:</p>
  
  <ol>
  <li><p><strong>An item page would be:</strong></p>
  
  <pre><code>www.domain.com/widgets/some-totally-awesome-large-purple-widget
  </code></pre></li>
  <li><p><strong>A category sub page page would be:</strong></p>
  
  <pre><code>www.domain.com/widgets/purple-widgets
  </code></pre></li>
  <li><p><strong>A category parent page page would be:</strong></p>
  
  <pre><code>www.domain.com/widgets/
  </code></pre></li>
  <li><p><strong>A custom page may be:</strong></p>
  
  <pre><code>www.domain.com/some-random-page
  </code></pre></li>
  </ol>
  
  <p>The various page types are too numerous to write individual Routers for.</p>
  
  <p>Using Router::connect I can easily account for the first and second scenarios using something like:</p>
  
  <pre><code>Router::connect('/{:pageroot}/{:pagekey}', 'Pages::index');
  </code></pre>
  
  <p>In turn, the Pages::index method looks for entries in our database with the "key" of '/widgets/purple-widgets'.</p>
  
  <p>However, the framework defaults to the '/{:controller}/{:action}/{:args}' route for pages like the third and fourth. I know that this is the correct behavior for the framework. Also, best practice would state that I should write the site to match this behavior. But, that isn't an option here.</p>
  
  <p>What I need is a Router that would allow the third and fourth examples to function the same as the first. All examples should be sent to the Pages::index controller, which in turn queries a database using the URL path as a key.</p>