We help IT Professionals succeed at work.

Check out this week's podcast, "Dairy Farms to Databases: Community's Hand in Technology"Listen Now

x

How to Get Apache on MAMP Pro to only server HTTPS

363 Views
Last Modified: 2019-03-03
I would like my Apache server to automatically connect all requests for a specific website using https:

I use MAMP Pro 5, running on Mac OS X 10.11.6  I have set up multiple websites, and for one specific domain I have successfully installed a SSL certificate that I purchased from namecheap.com
I can connect to the website securely if I type in the complete address, with https://

If I connect to the website without typing in https://  MAMP PRO's Apache server only serves up the pages without the secure connection

How can I have MAMP/Apache only connect visitors securely?
I've tried Allow http connections, but that doesn't redirect connections from http to https

MAMP Pro SSL settings for domain
Comment
Watch Question

Dr. KlahnPrincipal Software Engineer
CERTIFIED EXPERT

Commented:
We see this question every couple of weeks.  What you want to do requires mod_rewrite, in a config file or in a .htaccess file.  Here are links to the most recent responses:

https://www.experts-exchange.com/questions/29122361/forcing-site-to-https-and-working-both-for-www-or-non-www.html
(see lenamtl solution)

https://www.experts-exchange.com/questions/29002206/Apache-Rewrite-HTTP-To-HTTPS.html
(see DrDamnit solution)

Author

Commented:
Both of the links refer to what I'll call stand-alone Apache installs.  MAMP appears to relocate the files I need to change.  I can't find them to look at the Virtual Hosts.
Fractional CTO
CERTIFIED EXPERT
Distinguished Expert 2019
Commented:
This one is on us!
(Get your first solution completely free - no credit card required)
UNLOCK SOLUTION
CERTIFIED EXPERT

Commented:
Is this the MAMP from  OS X Server or from mamp.info?

The apache from OS X Server is located in the standard place /etc/apache2/ as is typical of many Linux distros.

Author

Commented:
It is the MAMP from mamp.info

I looked at the file in apache2  and it hadn't been modified.
CERTIFIED EXPERT

Commented:
The MAMP documentation shows that templates reside in your ~/Library/Application Support/appsolute/MAMP PRO/templates
https://documentation.mamp.info/en/MAMP-PRO-Mac/Menu/File/#edit_templates

and the http.conf file is in /Library/Application Support/appsolute/MAMP PRO/conf/

Author

Commented:
I made the changes below, and this simple Redirect is taking care of the redirect at the moment.
My job was to get a simple site to be redirected to https.  I will deal with the 301 issues should they be reported to me.

I contacted MAMP support, and they told me to implement this code in the httpd.conf

<VirtualHost *:80>
    ServerName www.example.com
    Redirect / https://www.example.com/
</VirtualHost>

--------------------------------------------------------------

I added:

<VirtualHost *:80>
    ServerName example.com
    Redirect / https://www.example.com/
</VirtualHost>

When I had set up the domain in MAMP, the virtual host in the  https-ssl.conf    had already been taken care of, so I didn't have to do anything to that template.

Author

Commented:
I appreciate the advanced looks ahead, and I will refer to those solutions should the need arise.
Unlock the solution to this question.
Join our community and discover your potential

Experts Exchange is the only place where you can interact directly with leading experts in the technology field. Become a member today and access the collective knowledge of thousands of technology experts.

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.