Fix: MAMP and HTTP to HTTP(S) Traffic Redirects

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.

 

Mamp http 404 not found

 

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.

 

  1. First, configure MAMP. Under Servers & Services go to Settings -> Ports and ensure MAMP is using default server ports 80 (http) and 443 (https).
 
 
Mamp server ports 80 443
 
 
  1. Under Servers & Services -> Apache and ensure ssl_module is enabled. (By default, this is enabled in MAMP)
 
  1. 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.
 
Note: There is now an option to Allow http connections in MAMP Pro. This will need to be enabled on the HTTPS host to get the http to https redirects to work.
 
 
MAMP ssl version website
 
 
  1. 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.





Mamp another host uses same folder

 

Mamp dual hosts red versions

 

  1. 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)
 
Mamp htaccess file
 
RewriteEngine on
RewriteCond %{HTTPS} !=on [OR]
RewriteCond %{HTTP_HOST} ^www\.DOMINANAME\.com$ [NC]
RewriteRule ^(.*)$ https\:\/\/DOMINANAME\.com\/$1 [L,R=301]
 

 

  1. Restart Apache.
 
 
Mamp restart apache
 
 
  1. 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.

 


* Please use the comment form below. Comments are moderated.*



 

Related Posts

 

Comments 4

urzh on Thursday, 30 August 2018 07:43

@Nino, which version of MAMP are you using? This was written for MAMP 4.

@Nino, which version of MAMP are you using? This was written for MAMP 4.
Guest - Nino on Tuesday, 28 August 2018 14:05

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?

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?
urzh on Sunday, 10 June 2018 10:16

Please tell me what part is not working for you?

Please tell me what part is not working for you?
Guest - Roee yossef on Sunday, 10 June 2018 02:39

Thanks for the info... but doing this doesnt work for me, what am i missing?

Thanks for the info... but doing this doesnt work for me, what am i missing?
Thursday, 21 November 2024