URL Manager


I wanted to direct every page request to pages controller since my site is content managed. I’m checking the URL and querying the database accordingly. I have use the below two methods.

1) 'pages/<sef_url:\w+>'=>'pages/index',

2) 'pages/<sef_url>'=>'pages/index',

The first method did not work and the second one did work. Now I can access the variable in the controller like below.

Actullay I got the idea from this post


Everything is fine but my question is what is the meaning of this :\w+ and :\d+. I referred the documentation but I do not understand it properly. Any help is greatly appreciated.


You’ll need to delve into regular expressions for that. Basically ‘\w’ represents word characters (with the plus indicating one or more of them), see this, and ‘\d’ represents decimal digits.

I presume your first expression is therefore not working because you have non-word characters in the url (another / for example).