I would probably use a simple module to always modify the route match
controller and action. If the module is enabled, the route will be set as
controller / action unless there is no route match in which case it will
404. I started out with some example code then formalised slightly as I
think I may find this useful at times.

<?php
namespace Trueaxiom\Module\SingleRoute;

use Zend\Mvc\MvcEvent;
use Zend\EventManager\EventInterface;
use Zend\ModuleManager\Feature\BootstrapListenerInterface;

/**
 * Modify Route Match to always return controller / action.
 */
class Module
{
    /**
     * @var string
     */
    protected $controller = 'Acl\Controller\Index';

    /**
     * @var string
     */
    protected $action = 'index';

    /**
     * Add Route Listener
     * @param  EventInterface $e
     */
    public function onBootstrap(EventInterface $e)
    {
         $e->getApplication()->getEventManager()->attach('route',
array($this, 'onRoute'), -1000);
    }

    /**
     * Route Listener Callback to Modify Route Match
     * @param  MvcEvent $e
     */
    public function onRoute(MvcEvent $e)
    {
        $rm = $e->getRouteMatch();
        $rm->setParam('controller', $this->controller);
        $rm->setParam('action', $this->action);
    }
}




On Wed, Aug 7, 2013 at 11:56 PM, Michael Gooden <[email protected]>wrote:

> Hi Tony,
>
> Create a segment route of '/*', and make sure it is registered last. This
> will catch all requests that could not be routed by existing routes.
>
> Cheers,
>
> Michael
>
>
> On 8 August 2013 00:53, tonystamp <[email protected]> wrote:
>
> > Hey all, i'm wondering if there's a way to redirect all requests to a
> > single
> > route?
> >
> > I am working on a site and want to upload the work-in-progress page, and
> > have all requests sent to that route that displays that page.
> >
> > When i tried editing my .htaccess to send all requests to that page it
> was
> > throwing up a 404, presumably because the request was not going through
> the
> > framework.
> >
> >
> >
> > --
> > View this message in context:
> >
> http://zend-framework-community.634137.n4.nabble.com/Redirecting-all-requests-to-one-route-tp4660699.html
> > Sent from the Zend Framework mailing list archive at Nabble.com.
> >
> > --
> > List: [email protected]
> > Info: http://framework.zend.com/archives
> > Unsubscribe: [email protected]
> >
> >
> >
>

Reply via email to