【问题标题】:Yii app uploaded on host brings up a 404 error when I call a specific action当我调用特定操作时,上传到主机上的 Yii 应用程序会引发 404 错误
【发布时间】:2014-09-24 22:02:15
【问题描述】:

我正在使用 xampp 开发我的应用程序,在那里一切正常。但是,当我将其上传到主机(托管商)并尝试访问特定页面时,我会收到 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 错误。

有人知道我为什么会收到此错误吗?谢谢你的帮助:)

【问题讨论】:

  • 控制器名称是什么?可能是您的控制器的名称,这就是问题所在。看看这个:stackoverflow.com/questions/25916671/…
  • 哇哦,就是这样。现在发表你的评论作为答案,这样我就可以给你一些代表你可爱的人:)

标签: php yii


【解决方案1】:

这与这里的问题类似:Yii 1.14 controller from two parts in module produce 404 error

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

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

【讨论】:

  • 没问题,很高兴为您提供帮助!
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2021-12-19
  • 2017-06-07
  • 2019-09-24
  • 1970-01-01
  • 2021-12-06
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多