原文章來自
it技術擎
Forbidden (#403)
You are not allowed to access this page.
The above error occurred while the Web server was processing your request.Please contact us if you think this is a server error. Thank you.
如果出到以上的錯誤,請確認你的配置是否是正確的。
$config['bootstrap'][] = 'debug';
$config['modules']['debug'] = 'yii\debug\Module';
$config['bootstrap'][] = 'gii';
$config['modules']['gii'] = array('class'=>'yii\gii\Module',
原始 的配置是這樣的,如果你的 使用的是本地的服務器的話,則不會存在問題。
如果你使用的是服務器的問題,就會出現以上的錯誤提示了
詳細分析得知,是Gii做了默認IP限定了
源代碼如下:
namespace yii\gii;
use Yii;
use yii\base\BootstrapInterface;
use yii\web\ForbiddenHttpException;
class Module extends \yii\base\Module implements BootstrapInterface
{
public $controllerNamespace = 'yii\gii\controllers';
public $allowedIPs = ['127.0.0.1', '::1'];
。。。。。。
源代碼做了限定了 只允許 127.0.0.1是可以訪問的其他都是不行的。
所以解決以上的問題
需要修改配置如下:
$config['bootstrap'][] = 'debug';
$config['modules']['debug'] = 'yii\debug\Module';
$config['bootstrap'][] = 'gii';
$config['modules']['gii'] = array('class'=>'yii\gii\Module',
'allowedIPs' => ['127.0.0.1', '::1', '192.168.*.*', '192.168.178.20'],
);
這樣在 allowedIPs 數組裏面的IP全部可以訪問了