4

Is it not possible in Mamp Pro 4 to have both http and https? The application I am working on requires both depending on the page.

I must be missing something as it makes no sense when I enable SSL only https works and http then stops working.

I tried going through the http.conf, but really have no idea whats causing this.

I think it just generates the vhost for https only and then removes http. Doesn't even look like you can manually edit it.

Any suggestion would be great.

limit
  • 647
  • 2
  • 8
  • 27

3 Answers3

12

Well to update my own post and if anyone else has this problem.

The software is currently not capable of this on the same hostname.

According to Mamp support you have to create two hosts with the same name (e.g. sample.app and sample.app.).

  1. Enable one of the "sample.app" hostnames to use SSL
  2. Enable the second host entry "sample.app" to not use SSL. (Don't forget to hold Alt or Option when clicking on +)
  3. Point both to the same directory.

Mamp will highlight this in red, as its warning that you have two of the same hostnames.

So currently this is the only solution I am aware of for this issue.

Hope they resolve this in future updates as a lot of applications, especially ecommerce rely on the ability to switch between http and https.

You can see this on the Mamp Pro documentation here.

Ricardo Martins
  • 5,702
  • 3
  • 40
  • 59
limit
  • 647
  • 2
  • 8
  • 27
  • this is literally the only thing to have ever worked for me outside of hacking config. +1 – kinghfb Nov 11 '16 at 17:12
  • 1
    I could not figure out how to add a second host with the same name until I realized I had to hold down ALT when pressing the plus sign to bypass the "Creating new host:" popup. I haven't seen this documented anywhere, though. I am on MAMP Pro v4.1.1 and macOS Sierra v10.12.3. – Scruffy Paws Feb 18 '17 at 22:47
  • Worked for me, thanks! It does feel like you shouldn't have to do this 'workaround' in Mamp Pro, you should just be able to hit a check box when setting up to enable both http and https for sites that require both. – Rob Ganly Dec 03 '17 at 21:38
4

I got a simple solution by edit template:

  1. Open Mamp Pro
  2. File > Edit Template > Apache > httpd-ssl.conf
  3. Add these line after

<VirtualHost *:80> ServerName MAMP_SSLVirtualHost_ServerName_MAMP MAMP_SSLVirtualHost_ServerAdmin_MAMP MAMP_SSLVirtualHost_DirectoryIndex_MAMP DocumentRoot MAMP_SSLVirtualHost_DocumentRoot_MAMP </VirtualHost>

MrDuy
  • 224
  • 2
  • 9
0

Mamp Pro 5 in 2020 Update

To tag onto MrDuy's great response, as the Alt Click on the + doesn't seem to work in V5, editing the httpd-ssl.conf template seems to be the way to go.

However MrDuy's answer assumes you're using port 80 for HTTP inside MAMP, which is not the default 8888. Additionally, and I can't speak for MAMP PRO 4 users, the snippet needs to be placed before the MAMP_SSLVirtualHost_iteration_end_MAMP line at the bottom of the file, as obviously this is the end marker that MAMP uses to conduct its iteration of the hosts in the GUI.

TLDR; Follow the first two steps in MrDuy's answer:

  1. Open MAMP Pro

  2. File > Edit Template > Apache > httpd-ssl.conf

Then, at the bottom of the file, locate the line with MAMP_SSLVirtualHost_iteration_end_MAMP Before this line, paste the following:

<VirtualHost *:8888>
    ServerName MAMP_SSLVirtualHost_ServerName_MAMP
    MAMP_SSLVirtualHost_ServerAdmin_MAMP
    MAMP_SSLVirtualHost_DirectoryIndex_MAMP
    DocumentRoot MAMP_SSLVirtualHost_DocumentRoot_MAMP
</VirtualHost>

It would've been niced to use the placeholder markers MAMP uses in it's non SSL config file (MAMP_VirtualHost_IP_MAMP, MAMP_VirtualHost_Port_MAMP etc) but obviously these aren't passed in the file. Which means that if you decide to change the HTTP port, you must also manually update this file.

@MAMP, can't we make this a default? :`(

Cheers!

Community
  • 1
  • 1
FrankieDee
  • 163
  • 1
  • 7
  • I should also add that one would typically use this setup to test for, ie, redirecting a http request to a secure https request – FrankieDee Apr 08 '20 at 02:51