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