root/trunk/config/routes.php

Revision 5, 3.1 KB (checked in by james, 2 years ago)

Added note to routes.php documentation about escaping dots.

Line 
1<?php
2
3// Where does the Maveric install live on the server?
4// ie: /path/to/maveric
5$base_url      = ''; // No trailing slash!
6
7/**
8 * Routes
9 *
10 * Routes are defined with regular expressions (for now), like so:
11 *
12 *   $routes[ regular expression ]
13 *      = array('controller/action', [param, [param ... ]]);
14 *
15 * You do not need to escape forward slashes (/).
16 *
17 * For example, to map the url /help to the "help" action of the
18 * DefaultController, you would use...
19 *
20 *   $routes['help/?'] = array('default/help');
21 *
22 * If you want to make the controller or action dynamic, you can
23 * use PCRE variables (ie: $1, $2, $3, etc). For example, if you
24 * wanted the URL format /controller/action, you could do:
25 *
26 *   $routes['([a-zA-Z_][\w_]+)/([a-zA-Z_][\w_]+)']
27 *     = array('$1/$2');
28 *
29 * You can also use certain shorthand notation to make your routes
30 * more readable. Currently, :controller, :action, :id, and :format.
31 * We can make the above example much cleaner:
32 *
33 *   $routes[':controller/:action'] = array('$1/$2');
34 *
35 * You can define additional parameters, which will be available
36 * in the $this->params array inside your controller. For example,
37 * to map the url /controller/action/id (where ID is a number):
38 *
39 *   $routes[':controller/:action/:id'] = array('$1/$2', 'id');
40 *
41 * So visiting /user/view/12 would execute UserController->view()
42 * and the params array would include $params['id'] = 12.
43 *
44 * You don't have to use this standard order. For instance, you could
45 * map /<username>/action.format to the UserController like so:
46 *
47 *   $routes['([\w]+)/:action\.:format']
48 *     = array('user/$2', 'username', 'format');
49 *
50 * As in the last example, be sure to escape any literal "."
51 * characters with a "\".
52 *
53 * The default action for any controller is "index", so if you no
54 * action is found, Maveric will try to execute the "index" method of
55 * the controller.
56 *
57 * Finally, you can define a default route, if no other route matches.
58 * The route should be "_default" and it will map to whatever
59 * controller and action you define without setting any parameters.
60 * This can be useful for 404 pages or mapping to your home page.
61 *
62 * Routes are processed in order, so routes defined first have higher
63 * priority. Make sure the _default route is last.
64 */
65$routes = array();
66
67/** Generic Routes : **/
68
69// /controller/action/id.format
70$routes[':controller/:action/:id\.:format'] = array('$1/$2', 'id', 'format');
71
72// /controller/action/id (optional trailing slash)
73$routes[':controller/:action/:id/?'] = array('$1/$2', 'id');
74
75// /controller/action.format
76$routes[':controller/:action\.:format'] = array('$1/$2', 'format');
77
78// /controller/action (optional trailing slash)
79$routes[':controller/:action/?'] = array('$1/$2');
80
81// /controller (optional trailing slash, defaults to "index" method)
82$routes[':controller/?'] = array('$1/index');
83
84/** Route for nothing, ie: $base_url/:
85 * Goes to DefaultController->index()
86 */
87$routes[''] = array('default/index');
88
89/** Set a default controller and action;
90 * Goes to DefaultController->fourohfour
91 */
92$routes['_default'] = array('default/fourohfour');
93
94?>
Note: See TracBrowser for help on using the browser.