Fix: MAMP and HTTP to HTTP(S) Traffic Redirects
If you are trying to successfully re-direct all HTTP to HTTPS traffic on an SSL website in MAMP, you may be missing a key step. Furthermore, you may have recently migrated an HTTP(S) website to MAMP and suddenly notice the HTTP to HTTP(S) redirects not working even if you kept your original .htaccess file with the rewrite conditions applied. When you try to access your site over port 80 (http), you may notice you get the following page.
The official MAMP documentation outlines how to do this in a .htaccess file and or through Apache, however you must ensure you are also creating an HTTP version of your host in MAMP. Follow the steps below.
- First, configure MAMP. Under Servers & Services go to Settings -> Ports and ensure MAMP is using default server ports 80 (http) and 443 (https).
- Under Servers & Services -> Apache and ensure ssl_module is enabled. (By default, this is enabled in MAMP)
- Create an SSL version (www and non-www) of your host in MAMP first. Check the SSL box and point to your SSL certificate files. Point this host to your site document root folder.
- Create a non-SSL version of your host in MAMP next. This is basically telling MAMP to configure another host with the same domain name that exists over port 80. Point this host to the same site document root folder.
Note: You will notice a warning that another version of your site already exists and uses same folder. You can ignore this. You will also notice both hosts will appear red in MAMP now – this is also OK.
- Add or verify your Rewrite rule in your .htaccess file now. Open your document root in MAMP and add the following rule to the bottom of your .htaccess file. (This is a re-write rule for Joomla)
RewriteEngine on
RewriteCond %{HTTPS} !=on [OR]
RewriteCond %{HTTP_HOST} ^www\.DOMINANAME\.com$ [NC]
RewriteRule ^(.*)$ https\:\/\/DOMINANAME\.com\/$1 [L,R=301]
- Restart Apache.
- Finally, ensure your forcing HTTPS in your backend. For Joomla, this setting is found in Global Configuration -> Force HTTPS -> Entire site.
Try browsing to an HTTP version page on your site and it should immediately re-direct to the HTTP(S) version now.
Comments 4
@Nino, which version of MAMP are you using? This was written for MAMP 4.
I'm not able to start my Apache server in MAMP when I created a non SSL and a SSL version which both use the same domain, any way to get around this?
Please tell me what part is not working for you?
Thanks for the info... but doing this doesnt work for me, what am i missing?