The principle of this method sounds perfectly fine, but filtering http(s) at this point is pretty late, because Yii has already started up and everything. It would be better to catch an redirect the request earlier.
I would do this in the .htaccess file.
Also make sure that your application creates the correct URLs for the different part so you avoid redirects as much as possible.

So instead of making a link for http and relying on .htaccess to rewrite to https make the link to https directly. This will save one rewrite and thus be faster.

I follow the guild link. https only allow at login page not overall page. That is good news but somehow it always say can't establish a connection to the server at localhost when i click the https://.../login page and other pages still work fine using http. Anyone face this problem before?
Pls help. Thx

Unable to connect
Firefox can't establish a connection to the server at localhost.
The site could be temporarily unavailable or too busy. Try again in a few
moments.
If you are unable to load any pages, check your computer's network
connection.
If your computer or network is protected by a firewall or proxy, make sure
that Firefox is permitted to access the Web.

I found a mixture of www.jaburo.net/?p=40 and yii's filter guide was the best solution as I wanted to redirect to HTTPS only on my proper server, whilst on my test server i wanted to keep with HTTP since I didn't have a proper SSL.

I defined the following in the main.php config (under params):
'force_https' => TRUE,

With the above approach, I can have a different config file on the main server and test server and if force_https is TRUE, it will redirect my login page, otherwise it will just skip through this validator.