Error 404 Unable to resolve the request

I got this error:




Error 404

Unable to resolve the request "PlanComment/update".



It works well on local but not work on server.

I also changed case sensitivity but still not work.

Here is my code:

PlanCommentController.php




<?php


class PlanCommentController extends Controller

{

	/**

	 * @var string the default layout for the views. Defaults to '//layouts/column2', meaning

	 * using two-column layout. See 'protected/views/layouts/column2.php'.

	 */

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


	/**

	 * @return array action filters

	 */

	public function filters()

	{

		return array(

		  	'accessControl', // perform access control for CRUD operations

		   //	'postOnly + delete', // we only allow deletion via POST request

		);

	}


	/**

	 * Specifies the access control rules.

	 * This method is used by the 'accessControl' filter.

	 * @return array access control rules

	 */

	public function accessRules()

	{

		return array(

			array('allow', // allow authenticated user to perform 'create' and 'update' actions

				'actions'=>array('update', 'delete'),

				'users'=>array('@'),

			),

			array('allow', // allow admin user to perform 'admin' and 'delete' actions

				'actions'=>array('delete'),

				'users'=>array('admin'),

			),

			array('deny',  // deny all users

				'users'=>array('*'),

			),

		);

	}

....



View file: _comment.php




<?php  $this->widget('booster.widgets.TbButtonGroup', array(

                      'htmlOptions' => array('class' => 'dropup'),

                      'buttons' => array(

                            array('items' => array(

                                array('label' => 'Delete Comment', 'url' => array('PlanComment/delete',            'id'=>$comment->id, 'plan_id'=>$comment->plan_id),

                                       'visible'=>(Yii::app()->user->id == $comment->user_id) ||   Yii::app()->user->isPlanAuthor($comment->plan_id)),

                                '---',

                                array('label' => 'Edit Comment', 'url' => array('PlanComment/update', 'id'=>$comment->id, 'plan_id'=>$comment->plan_id),

                                        'visible'=>(Yii::app()->user->id == $comment->user_id)),

                  )),),)); ?>



Config file: main.php




// uncomment the following to enable URLs in path-format

		'urlManager'=>array(

			'urlFormat'=>'path',

            // remove index.php

            'showScriptName'=>false,

            'caseSensitive'=>false,

			'rules'=>array(

                'home'=>'site/index',

                'plan'=>'plan/index',

                'video'=>'video/index',

                'login/<service:(google|google-oauth|yandex|yandex-oauth|twitter|linkedin|vkontakte|facebook|steam|yahoo|mailru|moikrug|github|live|odnoklassniki)>' => 'site/login',

                '<action:(login|register|logout|about)>' => 'site/<action>',

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

                '<controller:\w+>/update/<ten>_<id:\d+>'=>'<controller>/update',

				'<controller:\w+>/view_thanhvien/<ten>_<id:\d+>'=>'<controller>/view_thanhvien',

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

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

			),

		),



Where is wrong in my code ?

Please help.

There could be any of two possibilities,

Either the access rules not passed

or

the record you are going to update no exist in the database and database returns 404.

please verify you DB before doing anymore debug. and than post some url you are trying to access.

Thanks.

No, it’s not. Because it works well on local.

I’ll bet your local serv is on Windows. If I remember correctly there is this problem with camelcase controller’s name parsing. Stick with “Abcdefg” and not with “AbcDeg”

Try again with controller’s name changed to PlancommentController.

This problem was solved.

As @M Sost said:

  1. Change file name:

PlanCommentController.php -> PlancommentController.php

  1. Change definition in controller:

class PlanCommentController extends Controller

->


class Plancommentcontroller extends Controller

  1. Change url in view

'url' => array('PlanComment/update',

->


'url' => array('plancomment/update',

Work like charm. ;D

With your class named PlanCommentController, won’t a camel cased route work for you (‘planCommentController/action’)? I think by default, yii parses your routes as-is, so ‘planCommentController’ would look for a controller with the ID “planCommentController” (which is what yii would assign by default as your controller’s ID).

Your fix probably works because a class called "Plancommentcontroller" would have an ID of "plancommentcontroller", so it matches up with an all lower case route.