Mark Pegasov
Mark Pegasov

Reputation: 5289

Non-standard urls with Yii urlManager

I need to use urls like <controller>.<action>, for example: api.wwwhost.com/index.php?r=people.top

So, I've tried to write pattern

'urlManager'=>array(
    'urlFormat'=>'path',
    'showScriptName'=>false,
    'caseSensitive'=>false,
    'useStrictParsing'=>true,
    'rules'=>array(
        '<controller:\w+>.<action:\w+>' => '<controller>/<action>',
    ),
),

but it does not work. As I know, symbol "." not included in "\w+".

Where is my mistake?

Upvotes: 0

Views: 820

Answers (1)

thaddeusmt
thaddeusmt

Reputation: 15600

For me, when in "path" mode ('urlFormat'=>'path'), I cannot use the index.php?r=people/top style URLs. None of my ?r= style URLs work when I am in path mode. Do you experience the same thing?

They DO when when I am "get" mode ('urlFormat'=>'get'), but in get mode the URL rules are not processed, and it appears to default to only use '/' for delimiters.

You code DID work for me when I used this style URL:

api.wwwhost.com/people.top

When "path" mode is set (i.e. 'urlFormat'=>'path'), be sure to have your .htaccess file set up correctly to use it (hiding the index.php file). More info here in the Yii Guide about URLs.

Upvotes: 1

Related Questions