Daniel
(Info)
1
Hi everyone,
I have got the following problem with CUrlManager.
I defined several rules i.e.:
'einsaetze/<year:\d+>' => 'einsaetze/liste',
'einsaetze' => 'einsaetze/liste',
The prolem is that calling example.com/einsaetze will throw an exception (default action not found).
Some tracing and debugging brought me to CUrlManager’s method parseUrl:
public function parseUrl($request)
294 {
295 if($this->getUrlFormat()===self::PATH_FORMAT)
296 {
297 $rawPathInfo=urldecode($request->getPathInfo());
298 $pathInfo=$this->removeUrlSuffix($rawPathInfo,$this->urlSuffix);
299 foreach($this->_rules as $rule)
300 {
301 if(($r=$rule->parseUrl($this,$request,$pathInfo,$rawPathInfo))!==false)
302 return isset($_GET[$this->routeVar]) ? $_GET[$this->routeVar] : $r;
303 }
As you can see, parseUrl returns always the request var if it is set:
return isset($_GET[$this->routeVar]) ? $_GET[$this->routeVar] : $r;
I don’t get the sense behind these lines, is there a fault somewhere else?
Thanks,
Daniel
Y11
(Y!!)
3
Post full error message with backtrace please.
Did you configured the url-manager correct? For example $urlFormat must be "path" for your posted rules.
Daniel
(Info)
4
'urlManager' => array(
39 'class' => 'CUrlManager',
40 'urlFormat' => 'path',
41 'showScriptName' => false,
42 'rules' => array(
43 '/' => 'neuigkeiten/liste',
44 '/neuigkeiten' => 'neuigkeiten/liste',
45 '/inhalt/seite/<seite:(.*)>' => 'inhalt/seite',
46 '/einsaetze/<year:\d+>' => 'einsaetze/liste',
47 '/einsaetze' => 'einsaetze/liste',
48 ),
49 ),
Calling "http://www.example.com/einsaetze/2009":
(The first three rules work as expected.)
Daniel
(Info)
5
As no one seems to know an answer, I’d like to ask a yii core developer to explain this behavior.
Why does CUrlManager return always the request path (i.e. /einsaetze) if the get parameter is still set - no matter if it was resolved properly?
// Edit: I “fixed” it now by overloading it. In my opinion, if this is not a bug (and if I didn’t overseen something), this behavior is not senseful.
Daniel
(Info)
6
Never mind. My .htaccess set $_GET[‘r’] to the request string 
Thanks to everyone who read this topic 