title: redirect in cakephp ssl site routes to http not https
body: <p>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.com not  https: //subdomain.domain.com/controller/action.</p>
  
  <p>I have solved this by creating a virtual host for port 80 pointing to the cakephp application and added these rewrite rules in .htaccess</p>
  
  <p>RewriteCond %{HTTPS} off
  RewriteRule (.*) <a href="https://%" rel="nofollow">https://%</a>{HTTP_HOST}%{REQUEST_URI} [L]</p>
  
  <p>This catches this situation and redirect to https but this gives unnecessary extra traffic to the server. </p>
  
  <p>The cause for this extra traffic is the redirect function as it generates wrong urls. I have looked into the redirect function and it calls router::url to create the actual url. However I am not able to figure out how or where to instruct the router to use https not http.</p>
  
  <p>Tim</p>