title: redirect with .htaccess with cakePHP
body: <p>cakePHP already set this on /web/website/.htaccess</p>
  
  <pre><code>&lt;IfModule mod_rewrite.c&gt;
     RewriteEngine on
     RewriteRule    ^$ app/webroot/    [L]
     RewriteRule    (.*) app/webroot/$1 [L]
  &lt;/IfModule&gt;
  </code></pre>
  
  <p>Now I want to redirect all http to https and www to non-www</p>
  
  <p>I tried: </p>
  
  <pre><code> RewriteEngine on
  Options +FollowSymlinks -MultiViews
  
  
    RewriteCond %{HTTPS} off
    RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
    RewriteRule ^(.*)$ https://%1/$1 [R=301,L]
  
    RewriteCond %{HTTPS} on
    RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
    RewriteRule ^(.*)$ https://%1/$1 [R=301,L]
  
  RewriteRule ^$ app/webroot/    [L]
  RewriteRule (.*) app/webroot/$1 [L]
  </code></pre>
  
  <p>INPUT: <a href="http://www.example.com.br/website" rel="nofollow">http://www.example.com.br/website</a>
  OUTPUT: <a href="https://example.com.br/" rel="nofollow">https://example.com.br/</a> with internal server error
  SHOULD:  <a href="https://example.com.br/website" rel="nofollow">https://example.com.br/website</a></p>