I have developed a cakephp site that should use ssl for all pages. It works as expected except when I use redirect in a controller it redirects to http: //subdomain.domain.c
I found the error it was a misconfiguration of Apache.
Trying out Jamies solution, the site ended up in a redirect loop, because RequestHandler->isSSL() returned false even if the request was https. I then discovered that the $_SERVER['https'] was not set and the $_SERVER['port'] was 80, not 443 as expected.
At that point I have placed my ssl directives in sites-available/default,
SSLEngine on
SSLCertificateFile [path to cert file]
SSLCertificateKeyFile [path to keyfile]
Moving the ssl directives to the virtual host for the subdomain resolved the issue, with redirect loops.
Actually is also solved my initial problem because the method Router::url checks for $_SERVER['https'] if set it generates a url that starts with https: otherwise just http:
I have tested both Jameies solution and my own with rewrite rules in .htaccess and they both work as expected after the fix.
Tim