I'm having trouble redirecting HTTP to HTTPS with a self assigned SSL certificate generated by MAMP PRO using the following code in my .htaccess:

RewriteEngine On
RewriteCond %{HTTPS} !on
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}


RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}

I have also tried the patrol plugin for Craft, enabling/disabling dev mode and included 'enableCsrfProtection' => true, in my general.php

Also the .htaccess provided by Craft doesn't work for me.

2 Answers 2


The condition should be:

RewriteCond %{HTTPS} !=on

(You were missing the = sign.)

For more info, see our help article, How do I force SSL for CP requests?

  • Hi Brandon, thank you for your answer. Unfortunately adding the = sign doesn't resolve the issue. I've tried several approaches but none seem to work. I'm guessing that the problem lies elsewhere. Perhaps it's my MAMP PRO Apache configuration.
    – Hasco
    Nov 6, 2014 at 10:11
  • @hascoulijn Can you add those [NC,R=301,L] flags to the end of the RewriteRule line, like the help article has? Nov 6, 2014 at 15:35
  • I was using the exact code from the help article but it didn't work. But it looks like my http and https connections are treated like separate domains since the http completely ignores the .htacces while the https connection returns an Internal Server Error after inserting some junk value.
    – Hasco
    Nov 7, 2014 at 13:06
  • @hascoulijn In that case you should talk to your host. They may be doing something non-standard and have some advice on how to do this. Nov 7, 2014 at 15:21
  • Ultimately the help article and your answer were the solution, I just had to figure out how to successfully set up SSL with MAMP first.
    – Hasco
    Nov 10, 2014 at 13:47

I fixed this issue by duplicating my host in MAMP PRO without SSL checked, this has to do with the different ports being used for http and https by Apache. So I now have

example.dev with SSL enabled

http now redirects to https using the code from How do I force SSL for CP requests.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.