【问题标题】:Getting 404 when switching to production with yii framework使用 yii 框架切换到生产环境时出现 404
【发布时间】:2015-03-10 04:14:01
【问题描述】:

我正在使用yii框架开发,我在开发时一切正常。

今天早上我添加了一条新路由并将其推送到服务器,但我无法访问它,找不到 404 页面。我尝试更改访问规则以使每个人都可以访问它,但没有任何变化,仍然是 404。 我正在尝试通过此 url 访问更新方法:index.php?r=adminuser/update&id=5

这是控制器的代码:

class AdminUserController extends Controller {

  public function filters()
  {
    return array(
        'accessControl', // perform access control for CRUD operations
    );
  }

  public function accessRules()
  {
    return array(
        array('allow', 
            'actions' => array('index', 'create', 'update'),
            'users'   => array('@'),
        ),
        array('allow', 
            'actions' => array('admin', 'delete'),
            'roles'   => array('admin'),
        ),
        array('deny', // deny all users
            'users' => array('*'),
        ),
    );
  }
  public function actionUpdate($id)
  {
   $model=$this->loadModel($id);

   if(isset($_POST['AdminUser']))
     $model->save($_POST['AdminUser'])
   $this->render('update',array(
        'model'=>$model,
    ));
  }
}

感谢那些可以帮助我的人。

【问题讨论】:

    标签: php yii http-status-code-404 production-environment


    【解决方案1】:

    你的网址应该是index.php?r=adminUser/update&id=5

    【讨论】:

    • 人们必须在更新数据之前进行身份验证,在开发模式下它可以完美运行。但是我也尝试了您的解决方案,仍然是 404。我想知道,访问规则是自动覆盖,还是让我强制它?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-12-13
    • 1970-01-01
    相关资源
    最近更新 更多