当我调用特定操作时,上传到主机上的Yii应用程序会出现404错误


Yii app uploaded on host brings up a 404 error when I call a specific action

我正在使用xampp开发我的应用程序,在那里一切都很好。但当我把它上传到主机(hostinger)上并尝试访问特定页面时,我会收到404错误。

将我链接到该页面的按钮(来自不同的控制器)有一个url:

array('url'=>'Yii::app()->createUrl("symptomHistory/patientSymptomHistory",array("id"=>$data->primaryKey))',

(这是网格视图中的一个按钮)

它调用的操作如下:

public function actionPatientSymptomHistory($id)
{
    //create model doctor request and search the database for a doctor request between the doctor user and 
    //the patient user
    $doctorRequestModel = new DoctorRequests;
    $doctorPatientRequest = $doctorRequestModel->findByAttributes(array('doctorID'=>Yii::app()->user->id, 'userID'=>$id, 'doctorAccepted'=>1));
    //if there is an accepted doctor request between doctor and patient, show the patients's symptom history
    if(isset($doctorPatientRequest))
    {   
        $model = new Symptomhistory;

        //model for the patients data
        $patientModel = User::model()->findByPk($id);
        //empty array to store all the user's symptoms
        $symptomItems = array();
        //find all symptomHistory records belonging to the user
        $symptomHistoryModels = $model->findAllByAttributes(array('user_id'=>$id));
        //loop through all the symptomHistory records that belong to the user
        foreach($symptomHistoryModels as $symptom)
        {
            //switch case for event color. set color for each flag type
            switch($symptom->symptomFlag)
            {
                case '1':
                    $symptomColor = '#A1EB86';
                    break;
                case '2':
                    $symptomColor = '#CCCA52';
                    break;
                case '3':
                    $symptomColor = '#F25138';
                    break;
                default:
                    $symptomColor = '#36c';
            }
            //create event
            $symptomItem=array('title'=>$symptom->symptomTitle,
                                'start'=>$symptom->dateSymptomFirstSeen,
                                'end'=>$symptom->dateSearched,
                                'symptomCode'=>$symptom->symptomCode,
                                'symptomHistoryID'=>$symptom->id,
                                'flag'=>$symptom->symptomFlag,
                                'color'=>$symptomColor
            );
            //copy symptomHistory event into array
            array_push($symptomItems, $symptomItem);
        }
        //render patient history
        $this->render('patientSymptomHistory',array(
            'model'=> $model, 'patientModel'=> $patientModel, 'symptomHistoryEvents'=>$symptomItems
        ));
    }
    else //else throw exception
    {
        throw new CHttpException(403, 'You are not permitted to check this patient''s Symptom History');
    }
}

(很抱歉代码太长了,但我真的不知道什么可能有帮助,什么可能没有帮助)。

我再说一遍,我得到的是404错误,而不是403错误。

有人知道我为什么会犯这个错误吗?感谢您的帮助:)

这与这里的问题类似:Yii 1.14控制器从模块中的两个部分产生404错误

由于控制器的命名约定,环境之间的差异可能导致这种性质的404。由于大写和小写字符具有不同的ASCII值,因此某些环境对它们的评估会有所不同。

根据我的经验,按照以下模式命名控制器:FooController.php,其中Controller中的第一个字母和"C"都是大写的,没有其他内容,似乎适用于所有环境。