php - How to allow 'http' only in the Access Rules array
112
In Yii, I am finding a way how to restrict the url that accesses my controller actions to 'http' only. I am thinking about how to get the url in a Yii way so that I can place my code in the 'expression' attribute of the array.
Answer
Solution:
You can write a filter method in your base controller (
components/Controller.php
):It will redirect your
https://
tohttp://
requests. You can configure this filter for specific controller actions in amethod in a controller:
If you generally want that redirect all your
https
requests, then you could also put theif
above (without theelse
part) into theinit()
method of your base controller incomponents/Controller.php
.Answer
Solution:
Try defaultScheme/validSchemes
array('url', 'url','defaultScheme' => 'http')
array('url', 'url','validSchemes' => array('http'));
Check this for more info http://www.yiiframework.com/wiki/56/#hh23