Php 获取错误404在服务器上使用webapp时无法解析请求“ActionName”
我在yii框架中创建了一个webapp。它在本地主机上运行良好,但当我在服务器上部署它时,它抛出错误:Php 获取错误404在服务器上使用webapp时无法解析请求“ActionName”,php,.htaccess,yii,Php,.htaccess,Yii,我在yii框架中创建了一个webapp。它在本地主机上运行良好,但当我在服务器上部署它时,它抛出错误: Error 404 Unable to resolve the request "ActionName". 我检查了所有配置文件、所有URL和路径,但没有找到任何解决方案。甚至我从根目录中删除了.htaccess文件,但没有解决方案: 有人能帮我解决吗 我的main.php代码是: <?php return array( 'basePath' => dir
Error 404
Unable to resolve the request "ActionName".
我检查了所有配置文件、所有URL和路径,但没有找到任何解决方案。甚至我从根目录中删除了.htaccess文件,但没有解决方案:
有人能帮我解决吗
我的main.php代码是:
<?php
return array(
'basePath' => dirname(__FILE__) . DIRECTORY_SEPARATOR . '..',
'preload' => array('log'),
// autoloading model and component classes
'import' => array(
'application.models.*',
'application.components.*',
'ext.giix.components.*', // giix components
),
'modules' => array(
// uncomment the following to enable the Gii tool
'gii' => array(
'class' => 'system.gii.GiiModule',
'password' => 'jar',
'generatorPaths' => array(
'ext.giix.core', // giix generators
),
),
),
// application components
'components' => array(
'user' => array(
// enable cookie-based authentication
'allowAutoLogin' => true,
),
'ePdf' => array(
'class' => 'ext.yii-pdf.EYiiPdf',
'params' => array(
'HTML2PDF' => array(
'librarySourcePath' => 'application.vendors.html2pdf.*',
'classFile' => 'html2pdf.class.php', // For adding to Yii::$classMap
)
),
),
'session' => array(
'timeout' => 300,
'cookieMode' => 'only',
'cookieParams' => array('secure' => false, 'httponly' => false),
),
'db' => array(
'connectionString' => 'mysql:host=localhost;dbname=nameofdb',
'emulatePrepare' => true,
'username' => 'UN',
'password' => 'pass',
'charset' => 'utf8',
),
'errorHandler' => array(
// use 'site/error' action to display errors
'errorAction' => 'site/error',
),
'log' => array(
'class' => 'CLogRouter',
'routes' => array(
array(
'class' => 'CFileLogRoute',
'levels' => 'error, warning',
),
),
),
),
// application-level parameters that can be accessed
// using Yii::app()->params['paramName']
'params' => array(
// this is used in contact page
'adminEmail' => 'xyz@abc.com',
),
);
当我击球时
或任何其他内部url。我也犯了同样的错误
请帮我解决这个问题。什么是ActionName?将整个错误堆栈放入。当我点击任何链接时,我得到了同样的错误,无法解析请求ActionName。我还检查了控制器文件名和链接url名的大小写是否相同。没有错误堆栈,只有上面的错误。如果您确实需要帮助,请使用完整的错误和控制器代码更新您的问题,仅使用与您的问题相关的代码。否则,您可以自己检查main.php文件中的大小写敏感度。如果从windows传输到unix,则可能会产生问题..您好Stefano Mtangoo。。正如我所说,我的应用程序在localhost上运行良好,这表明我的代码中没有错误。必须保留任何配置设置。
class districtController extends Controller {
/**
* Declares class-based actions.
*/
public function actions() {
return array(
// captcha action renders the CAPTCHA image displayed on the contact page
'captcha' => array(
'class' => 'CCaptchaAction',
'backColor' => 0xFFFFFF,
),
// page action renders "static" pages stored under 'protected/views/site/pages'
); }
public function actionIndex() {
$this->render('index');
}
public function actionSda() {
$this->render('sda');
}
public function actionIqt() {
$this->render('iqt');
}
public function actionSm() {
$this->render('sm');
}
public function actionCreate() {
$model = new SchoolDetails;
// Uncomment the following line if AJAX validation is needed
// $this->performAjaxValidation($model);
if (isset($_POST['SchoolDetails'])) {
$model->attributes = $_POST['SchoolDetails'];
$model->setAttribute('school_doc', date('y:m:d, h:m:s'));
if ($model->save())
$this->redirect(array('view', 'id' => $model->school_id));
}
$this->render('create', array(
'model' => $model,
));
}
public function actionUpdate($id) {
$model = $this->loadModel($id);
// Uncomment the following line if AJAX validation is needed
// $this->performAjaxValidation($model);
if (isset($_POST['SchoolDetails'])) {
$model->attributes = $_POST['SchoolDetails'];
if ($model->save())
$this->redirect(array('view', 'id' => $model->school_id));
}
$this->render('update', array(
'model' => $model,
));
}
public function actionView($id) {
$this->render('view', array(
'model' => $this->loadModel($id),
));
}
public function actionDelete($id) {
$this->loadModel($id)->delete();
// if AJAX request (triggered by deletion via admin grid view), we should not redirect the browser
if (!isset($_GET['ajax']))
$this->redirect(isset($_POST['returnUrl']) ? $_POST['returnUrl'] : array('admin'));
}
public function actionAdmin() {
$model = new SchoolDetails('search');
$model->unsetAttributes(); // clear any default values
if (isset($_GET['SchoolDetails']))
$model->attributes = $_GET['SchoolDetails'];
$this->render('admin', array(
'model' => $model,
));
}
public function loadModel($id) {
$model = SchoolDetails::model()->findByAttributes(array('school_id' => $id));
if ($model === null)
throw new CHttpException(404, 'The requested page does not exist.');
return $model;
}
/* School Operations page actions Ends */
public function actionStudent_create() {
$model = new StudentDetails;
// Uncomment the following line if AJAX validation is needed
// $this->performAjaxValidation($model);
if (isset($_POST['StudentDetails'])) {
$school = SchoolDetails::model()->findByAttributes(array('school_name' => $_POST['StudentDetails']['student_school_name']));
$model->attributes = $_POST['StudentDetails'];
$model->setAttribute('student_doc', date('y:m:d, h:m:s'));
$model->setAttribute('school_id', $school->school_id);
if ($model->save())
$this->redirect(array('view', 'id' => $model->student_id));
}
$this->render('student_create', array(
'model' => $model,
));
}
public function actionUpdate_student($id) {
$model = $this->loadModel($id);
// Uncomment the following line if AJAX validation is needed
// $this->performAjaxValidation($model);
if (isset($_POST['StudentDetails'])) {
$school = SchoolDetails::model()->findByAttributes(array('school_name' => $_POST['StudentDetails']['student_school_name']));
$model->attributes = $_POST['StudentDetails'];
$model->setAttribute('student_doc', date('y:m:d, h:m:s'));
$model->setAttribute('school_id', $school->school_id);
if ($model->save())
$this->redirect(array('view', 'id' => $model->student_id));
}
$this->render('update_student', array(
'model' => $model,
));
}
public function actionView_student($id) {
$this->render('view_student', array(
'model' => $this->loadModel_Student($id),
));
}
public function loadModel_Student($id) {
$model = StudentDetails::model()->findByPk($id);
if ($model === null)
throw new CHttpException(404, 'The requested page does not exist.');
return $model;
}
protected function performAjaxValidation($model) {
if (isset($_POST['ajax']) && $_POST['ajax'] === 'lahaulandspiti-school-details-form') {
echo CActiveForm::validate($model);
Yii::app()->end();
}
}
/**
* This is the action to handle external exceptions.
*/
public function actionError() {
if ($error = Yii::app()->errorHandler->error) {
if (Yii::app()->request->isAjaxRequest)
echo $error['message'];
else
$this->render('error', $error);
}
}
}