Chapter 5. Zend_Controller_RewriteRouter
Prev |  | Next

## Chapter 5. Zend_Controller_RewriteRouter

## 5.1. Introduction

Zend_Controller_RewriteRouter is a new version of the framework router. Routing is the process of taking a URI endpoint and decomposing it to determine which controller and action of that controller, should receive the request. This definition of controller, action and optional parameters is packaged into a value object called Zend_Controller_Dispatcher_Token which is then processed by Zend_Controller_Dispatcher. Routing occurs only once: when the request is initially received and before the first controller is dispatched.

Zend_Controller_RewriteRouter is designed to allow for mod_rewrite like functionality using pure php structures. It is very loosely based on Ruby on Rails routing and does not require any prior knowledge of webserver URL rewriting. It is designed to work with a single mod_rewrite rule (one of):

    RewriteEngine on
    RewriteRule !\.(js|ico|gif|jpg|png|css)$ index.php

    RewriteEngine on
    RewriteCond %{SCRIPT_FILENAME} !-f
    RewriteCond %{SCRIPT_FILENAME} !-d
    RewriteRule ^(.*)$ index.php/$1

Prev |  | Next
4.4. Plugins | Home | 5.2. Using a router