caseSensitive strange routing behaviour

Hi there

When I browse to my ContentDetailController’s index action /contentdetail/ OR /contentDetail/ with caseSensitive set to false it doesn’t show my contentdetail.php layout file. Sometimes it loads the /views/contentDetail/index.php. When I remove the caseSensitive config setting from the main.php file, I can access the layout correctly through /contentDetail/. Is setting the caseSensitive config property the correct way to go about routing with case in Controller class names , like I have with ContentDetailController? I also tested with a controller name of DetailController.php, which worked perfectly when I accessed its actions like /detail/test.

I know I can set ruls for urlManager in the config file, but I really want some clarity on my issue.

I have the following setup:

  • Operating System: Ubuntu 11.04 running in VirtualBox

  • Web Server: Apache 2

  • Browser Type: Firefox

  • Version 1.1.9 January 1, 2012

/controllers/ContentDetailController.php

/views/contentDetail.index.php

/views/layouts/contentdetail.php

ContentDetailController.php




<?php


class ContentDetailController extends BaseController

{

    public $layout = '//layouts/contentdetail';

    

	public function actionIndex()

	{

		$this->render('index');

	}

    }

}

?>



config/main.php




'caseSensitive' => false,



/layouts/contentdetail.php




<?php $this->beginContent('//layouts/main'); ?>


<div class="container_12">

   

</div>


<?php $this->endContent(); ?>



My Application Log output




10:20:48.186086 	error 	exception.CHttpException.404 	


exception 'CHttpException' with message 'Unable to resolve the request

"contentdetail".' in

/var/www/tracc/yii/framework/web/CWebApplication.php:280

Stack trace:

#0 /var/www/tracc/yii/framework/web/CWebApplication.php(135):

CWebApplication->runController('contentdetail')

#1 /var/www/tracc/yii/framework/base/CApplication.php(162):

CWebApplication->processRequest()

#2 /var/www/tracc/wgll/frontend/www/index.php(34): CApplication->run()

#3 {main}

REQUEST_URI=/contentdetail

---



Hi Bjorn,

First:

When you have a Controller, to get its url route case sensitive is lowercase the first character and remove the word Controller. So If you have


/controllers/ContentDetailController.php

its url would be


/contentDetail

.

Second:

When your request can not be resolved to the controller specifying the layout, you of course can not see page in that layout, because SiteControllers actionError ist loaded instead of ContentDetailController.

I know I have to access the controller /contentDetails/, but I don’t want to. I want to be able to access it /contentdetail/ wihtout renaming my controller

Seems to be a bug, I created an issue on google code:

http://code.google.com/p/yii/issues/detail?id=3100

EDIT: just seen that commend from qiang: http://code.google.com/p/yii/issues/detail?id=2746#c1

Guess this isn’t easy to solve, maybe controllerMap as mentioned in that issue can help you…

Hi Bjorn,

please read this comment:

http://code.google.com/p/yii/issues/detail?id=3100#c5

It should give you all information you need to solve your problem.

Jip, that solved my problem. Thanks alot!

It would be bit of a shlep to add maps for all controllers having the same type of naming connvetion as mine. One would hope that caseSensitive will work as expected :slight_smile: