computerlarry
asked on
How to Get Apache on MAMP Pro to only server HTTPS
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
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
ASKER
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.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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.
The apache from OS X Server is located in the standard place /etc/apache2/ as is typical of many Linux distros.
ASKER
It is the MAMP from mamp.info
I looked at the file in apache2 and it hadn't been modified.
I looked at the file in apache2 and it hadn't been modified.
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/
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/
ASKER
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.
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.
ASKER
I appreciate the advanced looks ahead, and I will refer to those solutions should the need arise.
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)