Oh yeah!  I tried that once too and ended up writing a helper to extend
HtmlHelper and override the behavior of link based on, in one case, extra
passed params, and, in another, a record in the DB for records to be pushed
into SSL.  What the hell did I do with that thing??

MM

On Fri, May 13, 2011 at 11:49 PM, Jeremy Burns | Class Outfit <
[email protected]> wrote:

> Just a thought... So ideally you want the link on the page to be
> https/http, so that it goes straight there when clicked? Could you extend
> the Html helper to achieve this so that when you use $this->Html->link it
> does the logic and issues either a secure or an insecure link? This would
> avoid the logic + redirect on arrival at the target page...I think.
>
> Jeremy Burns
> *Class Outfit*
> *
> *
> [email protected] <[email protected]>
> http://www.classoutfit.com
>
> On 14 May 2011, at 04:44, Krissy Masters wrote:
>
> Thanks for your detailed help but still not what I am referring to. I have
> a force / unforce ssl for urls but that usually is forced by general surfing
> on the site if user is on a page requiring SSL then the function
> redirects….pretty simple.
>
> What I am saying is in the controller, in an action itself you have
> redirect() for whatever reason so send user to another url, now if this url
> your sending them to requires SSL for example your redirecting them once
> with the controller redirect…..and beforeRender hits them with a second
> redirect to force the ssl. It would be easier to simply say in the
> controller redirect that im sending you to a https url if needed rather than
> double redirects.
>
> Look at firebug to inspect the requests and the way you mention you get 2
> requests fired off resulting in 302 redirects.
>
> Controller sends to http://site.com/page (302 redirect #1)
> Gets to http://site.com/page hit with the second redirect 302 since it
> should be ssl for this example
> So finally after the second redirect you end up at https://site.com/page.
>
> All I was asking is there was a way to simply call the redirect() in the
> controller to force the ssl right there and then.
>
>
>
>
>
> *From:* [email protected] [mailto:[email protected]] *On
> Behalf Of *Matt Murphy
> *Sent:* Saturday, May 14, 2011 12:21 AM
> *To:* [email protected]
> *Subject:* Re: Force redirect to be SSL
>
> I've done this before with a component which i'd include in relevant
> controllers and call in needed methods.
>
> ------------
> <?php
> class SslComponent extends Object {
>
>     var $controller;
>
>     function startup(&$controller) {
>         $this->controller =& $controller;
>     }
>
>     function force() {
>         if(!$this->__isSSL()) {
>             $this->controller->redirect('https://'.$this->__url());
>         }
>     }
>
>     function unforce($path = '') {
>         if($this->__isSSL()) {
>             $this->controller->redirect('http://'.$this->__url($path));
>         }
>     }
>
>     function __url( $path = '') {
>         $path = $path ? $path : env('REQUEST_URI');
>         return env('SERVER_NAME').$path;
>     }
>
>     function __isSSL() {
>         if (env('SERVER_PORT')==443) {
>             return true;
>         } else {
>             return false;
>         }
>     }
> }
> --------------------------
> In my controllers, I htink I'd call $this->Ssl->force(); on the methods I
> wanted to be in SSL and ->unforce() in the rest (which is grossly inferior
> to using the .htaccess method!).  Warning:  It was not possible, using this,
> to go from ssl to non-ssl or visa versa with POST values intact (something
> this shares with the .htaccess rewrite method.).  Sorry if the above is off
> , but the idea should be clear enough.
>
> Er, this is also old as hell.  Written for 1.1, I think.
>
> MM
> On Fri, May 13, 2011 at 6:43 PM, Krissy Masters <
> [email protected]> wrote:
> Not using any htaccess files.
> I only have 2 redirects that I need to force to SSL I was just curious if
> there was a way.
>
> Maybe this is something future versions of cake might incorporate?
>
> Allow an additional param for SSL => true to force the redirect to be ssl
> rather than a double redirect.
>
>
> --
> Our newest site for the community: CakePHP Video Tutorials
> http://tv.cakephp.org
> Check out the new CakePHP Questions site http://ask.cakephp.org and help
> others with their CakePHP related questions.
>
>
> To unsubscribe from this group, send email to
> [email protected] For more options, visit this group
> at http://groups.google.com/group/cake-php
>
> --
> Our newest site for the community: CakePHP Video Tutorials
> http://tv.cakephp.org
> Check out the new CakePHP Questions site http://ask.cakephp.org and help
> others with their CakePHP related questions.
>
>
> To unsubscribe from this group, send email to
> [email protected] For more options, visit this group
> at http://groups.google.com/group/cake-php
>
> --
> Our newest site for the community: CakePHP Video Tutorials
> http://tv.cakephp.org
> Check out the new CakePHP Questions site http://ask.cakephp.org and help
> others with their CakePHP related questions.
>
>
> To unsubscribe from this group, send email to
> [email protected] For more options, visit this group
> at http://groups.google.com/group/cake-php
>
>
>  --
> Our newest site for the community: CakePHP Video Tutorials
> http://tv.cakephp.org
> Check out the new CakePHP Questions site http://ask.cakephp.org and help
> others with their CakePHP related questions.
>
>
> To unsubscribe from this group, send email to
> [email protected] For more options, visit this group
> at http://groups.google.com/group/cake-php
>

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
[email protected] For more options, visit this group at 
http://groups.google.com/group/cake-php

Reply via email to