Yii Framework Forum: CUrlManager default route - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

CUrlManager default route Catch-all pattern Rate Topic: -----

#1 User is offline   cass 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 59
  • Joined: 01-February 09
  • Location:London, UK

Posted 04 October 2011 - 09:02 AM

Hi All,

I am trying to create a catch-all rule at the very bottom of my CURLManager application instance so that anything that does not match the previous rules, will be handled by a particular module/controller/action.

After some research, I've stumbled into something along the lines of

		'urlManager'=>array(
			'urlFormat'=>'path',
			"showScriptName"=>false,
			'rules'=>array(

				'admin'=>'user/user/login',
				'admin/<controller:\w+>'=>'admin/<controller>',
				'admin/<controller:\w+>/<id:\d+>'=>'admin/<controller>/view',
				'admin/<controller:\w+>/<action:\w+>/<id:\d+>'=>'admin/<controller>/<action>',

				'<controller:\w+>/<id:\d+>'=>'<controller>/view',
				'<controller:\w+>/<action:\w+>/<id:\d+>'=>'<controller>/<action>',
				'<controller:\w+>/<action:\w+>'=>'<controller>/<action>',

				''=>'frontend/page/index',



			),
		),


But the '' at the end only works when there is nothing on the URL, e.g., no wildcards allowed.

If I replace the last line with

				'(.*)/*'=>'frontend/page/index',


The catch-all functionality does work, but then the /admin, for instance, never gets matched.

Any advice or implementation ideas?

Cheers,

Cass
0

#2 User is offline   dckurushin 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 392
  • Joined: 16-March 11
  • Location:Israel

Posted 04 October 2011 - 11:33 AM

(.*)/?(.*) ???

Its look like boobs, but it is actually the answer :lol:

theoretically (.*) should much all...
2

#3 User is offline   cass 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 59
  • Joined: 01-February 09
  • Location:London, UK

Posted 04 October 2011 - 12:51 PM

The boobs work like a treat! Many many thanks.
0

#4 User is offline   Dana 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 203
  • Joined: 18-February 10
  • Location:Florida, USA

Posted 07 March 2013 - 03:30 PM

Thanks!! I spent a good portion of the afternoon on this one, expecting 'useStrictParsing' turned off would allow the error action to kick in and blaming NGINX for not allowing Yii to handle the errors :P

Had to finally add a catch all of

'(.*)/?(.*)'=>'site/error'


--

NOTE: This only seems to be the case when using NGINX with fastcgi_intercept_errors on and a defined error page that is the yii bootstrap page. No other site has ever had the issue with the route not being handled by default when strict parsing was off.
0

#5 User is offline   Dana 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 203
  • Joined: 18-February 10
  • Location:Florida, USA

Posted 07 March 2013 - 03:43 PM

Actually, that doesn't work for the problem I'm having, because while it allows it to fall through to site/error, it doesn't actually treat it AS an error.

Back to swearing at NGINX...
1

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users