今天尝试在家里连接公司外部服务器的yii框架的gii功能,提示
Forbidden (#403)
You are not allowed to access this page.
于是花了较长的时间在百度和论坛上寻找yii2 外部pc端访问gii功能时的配置方法, 大多都是说需要找到main.php文件,然后改变默认的ip访问地址(127.0.0.1)实现, 但是找了半天无果。 自己官网文档找了好久解决方案如下:
在文件vendor\yiisoft\yii2-gii\Module.php 中
/**
* @var array the list of IPs that are allowed to access this module.
* Each array element represents a single IP filter which can be either an IP address
* or an address with wildcard (e.g. 192.168.0.*) to represent a network segment.
* The default value is `['127.0.0.1', '::1']`, which means the module can only be accessed
* by localhost.
*/
public $allowedIPs = ['115.123.134.185(替换为你现在的电脑ip)', '::1'];
解决了一个小问题。
2016-07-13 更正: 本着不随意修改源码的原则, 直接在配置文件进行配置修改;
修改如下: