1. 程式人生 > >yii2 中gii/debug訪問時出現403禁止訪問

yii2 中gii/debug訪問時出現403禁止訪問

主要是因為訪問的地址限制,預設只能本地測試訪問。本來這些除錯資訊也不應該在正式環境中展示。
但是需要使用,也可以特別申明訪問地址允許使用。

地址是指訪問的客戶端地址,不是伺服器地址!!!

tips:我使用的是yii2 advanced版本,在config/main-local.php

$config = [
    'components' => [
        'request' => [
            // !!! insert a secret key in the following (if it is empty) - this is required by cookie validation
'cookieValidationKey' => 'EcpqEDRY6XWo8TzwkMNadaZGPx0z7elO', ], ], ]; if (!YII_ENV_TEST) { // configuration adjustments for 'dev' environment $config['bootstrap'][] = 'debug'; $config['modules']['debug'] = [ 'class' => 'yii\debug\Module', 'allowedIPs'
=> ['127.0.0.1', '183.192.95.221'] ]; $config['bootstrap'][] = 'gii'; $config['modules']['gii'] = [ 'class' => 'yii\gii\Module', 'allowedIPs' => ['127.0.0.1', '183.192.95.221'] ]; } return $config;