From d4e95072203a5cf4f1d50d16fe3e490f275a4307 Mon Sep 17 00:00:00 2001 From: admin Date: Sat, 26 Aug 2006 01:15:06 +0000 Subject: --- user_guide/general/routing.html | 29 ++++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) (limited to 'user_guide/general/routing.html') diff --git a/user_guide/general/routing.html b/user_guide/general/routing.html index c6e8bd9cf..977698b9f 100644 --- a/user_guide/general/routing.html +++ b/user_guide/general/routing.html @@ -85,8 +85,13 @@ To overcome this, Code Igniter allows you to remap the URI handler.

Setting your own routing rules

-

Routing rules are defined in your application/config/routes.php file. In it you'll see an array called $route, that -you can use to specify your own routing criteria. A typical route might look something like this:

+

Routing rules are defined in your application/config/routes.php file. In it you'll see an array called $route that +permits you to specify your own routing criteria. Routes can either be specified using wildcards or Regular Expressions + + +

Wildcards

+ +

A typical wildcard route might look something like this:

$route['product/:num'] = "catalog/product_lookup"; @@ -125,8 +130,21 @@ Higher routes will always take precedence over lower ones.

Important: Do not use leading/trailing slashes.

+

Regular Expressions

+ +

If you prefer you can use regular expressions to define your routing rules. Any valid regular expression is allowed, as are back-references.

+ +

Note:  If you use back-references you must use the dollar syntax rather then the double backslash syntax.

+ +

A typical RegEx route might look something like this:

+ +$route['products\/([a-z]+)\/(\d+)'] = "$1/id_$2"; -

Reserved Route

+

In the above example, a URI similar to products/shirts/123 would instead call the shirts controller class and the id_123 function.

+ +

You can also mix and match wildcards with regular expressions.

+ +

Reserved Routes

There are two reserved routes:

@@ -144,6 +162,11 @@ Please read the Scaffolding page for details.

+ + + + + -- cgit v1.2.3-24-g4f1b