Top25
Top25

Reputation: 121

PHP MVC with SEO friendly URL

I know this,

http://hostname/params1/params2

params1 represent model name and params2 represent action name.

But If i have a model class name like ReceivedRequest, how i convert all lowercase in params1(receivedrequest) to class name format? That case often happens during MVC development

Upvotes: 1

Views: 740

Answers (1)

G_Gus
G_Gus

Reputation: 150

In Yii you can set the url rules caseSensitive option to false (the default is true)

To do that, assuming the default controller/action rule, in your configuration: in your configuration:

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

And note, if you do that, that as a result you should follow the convention that you use lower case when specifying controller mapping (CWebApplication::controllerMap) and action mapping (CController::actions).

Also, the directory names for organizing controllers should be in lower case.

See http://www.yiiframework.com/doc/api/1.1/CUrlManager

Upvotes: 2

Related Questions