I am new in yii framework. In my site gii shows the error
Error 403 You are not allowed to access this page.
I set the gii in the config file like this
'gii'=>array(
'class'=>'system.gii.GiiModule',
'password'=>'test123',
'ipFilters'=>array('192.168.0.101','127.0.0.1','::1'),
),
still it show the error
Following on from sandy8086's good answer. If your remote host is dual stacked (IPv6/IPv4) then you may have a dynamic IPv6 address automatically allocated in your subnet prefix range. The IPv4 method of using a wildcard '*' can also be adopted with the IPv6 address, thus: 'ab01:1234:5678:abcd:*', if you had a /64 prefix, this would match any address on your IPv6 network. This worked for me and got when I had trouble with the 'Error 403' and the penny dropped when I discovered, using Yii::app()->request->userHostAddress, that I was connecting via IPv6.
To fix this, look in your main config file for the modules section for Gii, and add an
ipFilters array that includes your own IP:
// protected/config/main.php
return array(
The ipFilters property can include as many items as you like, and they can be straight
IP addresses or wildcards such as "192.168.1.*".
IPv6 addresses are supported as well if the underlying platform supports it, and "::1"
represents localhost (which may be required in some configurations).
Be careful not to open Gii to a too-wide audience lest it become a security risk.
Note: Yii 1.1.6 adds the default filter directly to the stock config file:
// If removed, Gii defaults to localhost only. Edit carefully to taste.
hope solved your problem..
I was getting the same error. I checked my IP with
Yii::app()->request->userHostAddress
; turns out that this is returning an IPv6 address which looks something liks thisab01::1
. This may be the behavior especially if you are using Safari (on OS X ... Chrome on OS X is showing the normal 127.0.0.1 IP. Strangely odd behavior from these two WebKit browsers).So, simply put
Yii::app()->request->userHostAddress
in one of your views, and then copy the result from the output, and paste it in config/main.php:You may set...
From the docs http://www.yiiframework.com/doc/api/1.1/GiiModule#ipFilters-detail ...
Make sure theres no pregenerated config at the bottom of the config file. Those will overwrite whatever you added above:
Should become (example, allows anyone):
This is the only line that worked for me: