Forbidden (#403)You are not allowed to access this page.

添加GII的IP白名单:

在config/web.php修改gii的allowedIPs

修改完仍然不行,一般是在虚拟机中的运行环境:
定位到:yii\gii\Module,在下面代码中打印出获取的IP添加到gii白名单:
protected function checkAccess()
{
    $ip = Yii::$app->getRequest()->getUserIP();
    //echo $ip ;exit(); 断点输出ip,添加进配置
    foreach ($this->allowedIPs as $filter) {
        if ($filter === '*' || $filter === $ip || (($pos = strpos($filter, '*')) !== false && !strncmp($ip, $filter, $pos))) {
            return true;
        }
    }
    Yii::warning('Access to Gii is denied due to IP address restriction. The requested IP is ' . $ip, __METHOD__);

    return false;
}

你可能感兴趣的:(yii,php)