<p>The condition should be:</p>

<pre><code>RewriteCond %{HTTPS} !=on
</code></pre>

<p>(You were missing the <code>=</code> sign.)</p>

<p>For more info, see our help article, <a href="http://buildwithcraft.com/help/force-ssl" rel="nofollow">How do I force SSL for CP requests?</a></p>

CC BY-SA 3.0
2014-11-06T10:11:11.387Z
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
CC BY-SA 3.0
2014-11-06T15:35:17.000Z
@hascoulijn Can you add those `[NC,R=301,L]` flags to the end of the `RewriteRule` line, like the help article has?
Brandon Kelly
CC BY-SA 3.0
2014-11-07T13:06:02.560Z
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
CC BY-SA 3.0
2014-11-07T15:21:35.707Z
@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.
Brandon Kelly
CC BY-SA 3.0
2014-11-10T13:47:25.607Z
Ultimately the [help article](http://buildwithcraft.com/help/force-ssl) and your answer were the solution, I just had to figure out how to successfully set up SSL with MAMP first.
Hasco
CC BY-SA 3.0
2014-11-05T23:19:07.843Z
2014-11-05T23:19:07.843Z
Brandon Kelly
<p>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 <code>http</code> and <code>https</code> by Apache. So I now have</p>

<pre><code>example.dev
example.dev with SSL enabled
</code></pre>

<p><code>http</code> now redirects to <code>https</code> using the code from <a href="http://buildwithcraft.com/help/force-ssl" rel="nofollow">How do I force SSL for CP requests</a>.</p>

CC BY-SA 3.0
2014-11-07T13:50:03.523Z
2014-11-07T13:50:03.523Z
Hasco
<p>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:</p>

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

<p>or</p>

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

<p>I have also tried the <a href="https://github.com/selvinortiz/craft.patrol" rel="nofollow">patrol</a> plugin for Craft, enabling/disabling dev mode and included  <code>'enableCsrfProtection' =&gt; true,</code> in my <code>general.php</code></p>

<p>Also the .htaccess <a href="http://buildwithcraft.com/help/force-ssl" rel="nofollow">provided by Craft</a> doesn't work for me.</p>

<htaccess><https>
How can I redirect HTTP to HTTPS with a local self assigned SSL certificate in my .htaccess?
# How can I redirect HTTP to HTTPS with a local self assigned SSL certificate in my .htaccess?

(Asked by: username_0 on 2014-11-05)

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}

or
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.

**Tags:** htaccess, https


---

## 2 answers

### Answer by username_1 on 2014-11-05. Score: 4 | Accepted answer

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?

> **Comments:**
> **username_0**: 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.  
> **username_1**: @hascoulijn Can you add those `[NC,R=301,L]` flags to the end of the `RewriteRule` line, like the help article has?  
> **username_0**: 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.  
> **username_1**: @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.  
> **username_0**: Ultimately the [help article](http://buildwithcraft.com/help/force-ssl) and your answer were the solution, I just had to figure out how to successfully set up SSL with MAMP first.  

---

### Answer by username_0 on 2014-11-07. Score: 1

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
example.dev with SSL enabled

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


---

