php - Redirect loop when using Yii ip access rule
Get the solution ↓↓↓Using Yii 1.1.15. I want to restrict the login and logout actions by ip rule. I have this inside the controller:
public function accessRules()
{
return [
[
'allow',
'actions' => ['index', 'error'],
'users' => ['*'],
],
[
'allow',
'actions' => ['login'],
'users' => ['*'],
'ips' => ['xx.yy.zz.qq'],
],
[
'allow',
'actions' => ['logout'],
'users' => ['@'],
'ips' => ['xx.yy.zz.qq'],
],
[
'deny', // deny all users
'users' => ['*'],
],
];
}
But when I call the login action in the browser, the browser enters a redirect loop. If I comment out theips
rule, it works.
What is wrong with the above code?
Answer
Solution:
This has finally proved to be a bug that exists in both 2.0 and 1.1 branches. It's already been fixed in 2.0 branch (scheduled for the 2.0.1 milestone) and I've created a pull request for the 1.1 branch.
The issue for the 2.0 branch is at https://github.com/yiisoft/yii2/issues/4889
Share solution ↓
Additional Information:
Link To Answer People are also looking for solutions of the problem: xml parsing error: no root element found
Didn't find the answer?
Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.
Similar questions
Find the answer in similar questions on our website.
Write quick answer
Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.