Allow Only 'http' Only In Access Rules

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.

If you have the answer or any suggestions, it will be a great help. Thanks!

array(‘Link’,‘CRegularExpressionValidator’, ‘pattern’=>"/^(http):\/\/([A-Z0-9][A-Z0-9_-](?:\.[A-Z0-9][A-Z0-9_-])+):?(\d+)?\/?/i",‘message’=>'Your URL must contain http://),

above regular expression allow only http.


I wrote this filter to allow only https but you can modify it to only allow http instead.



 * HttpsFilter class file.


 * @author Matt Skelton

 * @date 6-Jul-2011



 * Forces a controller to redirect to HTTPS.


class HttpsFilter extends CFilter


    protected function preFilter($filterChain)


        if (!Yii::app()->getRequest()->isSecureConnection)


            # Redirect to the secure version of the page.

            $url = 'https://' .

                Yii::app()->getRequest()->serverName .



            return false;


        return true;