Home  >  Article  >  PHP Framework  >  What should I do if the yii2 project Action reports a 403 error?

What should I do if the yii2 project Action reports a 403 error?

藏色散人
藏色散人Original
2020-07-20 10:00:043112browse

The solution to the 403 error reported by the yii2 project: first open the corresponding code file; then modify the writing method in the ACF verification; finally, separate the words with "-" symbols to solve the 403 error.

What should I do if the yii2 project Action reports a 403 error?

##yii2.0 Action reports 403 error [2.0 version]

When you are editing an action, Maybe it's a word, maybe it's a spliced ​​word, such as actionGet(); actionSpecialCallback();

Recommended: "

yii tutorial"

When you meet actionSpecialCallback() ; When using this method, the way you write in ACF verification is to use - to separate words between words, and there will be no 403 error, as shown below:

use yii\filters\AccessControl;
class SiteController extends Controller
{
    public function behaviors()
    {
        return [
            'access' => [
                'class' => AccessControl::className(),
                'only' => ['special-callback'],
                'rules' => [
                    [
                        'actions' => ['special-callback'],
                        'allow' => true,
                        'matchCallback' => function ($rule, $action) {
                            return date('d-m') === '31-10';
                        }
                    ],
                ],
            ],
        ];
    }
    // Match callback called! This page can be accessed only each October 31st
    public function actionSpecialCallback()
    {
        return $this->render('happy-halloween');
    }
}

The above is the detailed content of What should I do if the yii2 project Action reports a 403 error?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn