Redirecting domain in apache2.conf

March 1, 2018 660 views
Apache Ubuntu 16.04

This is an odd question - I need to redirect traffic from https to http temporarily. I had a cert on our old, self-hosted server but don't have one yet on our DO server as I'm still learning my way around the command line and waiting on our CA to issue the cert.

Anyway, visitors to the old site with the cert now go to the new site and are unable to connect because their browser defaults to https thus making the site unreachable. Until I get the updated cert in place, I wanted to redirect all traffic from https to http temporarily and then reverse that once the cert is working.

I tried a couple of tutorials but didn't find anything definitive and the few changes I did make either did nothing or caused the site to lock up until I removed the offending code.

Can anyone tell me how to do this redirect?

Many thanks in advance.

1 Answer

Hello,

In order to setup HTTPS redirect to HTTP, you would need to have an SSL already installed in Apache so that it could listen on port 443.

However if the SSL certificate is not valid there would still be a browser SSL warning. When you open up the website in a browser, it sends a secure handshake request. This comes before the website content / Apache directives / .htaccess redirects come in place.

Practically an attempted connection over https:// will always display a security error if there is no SSL for the domain. It's a security measure so that connections over SSL will be established only after the validity of the SSLs has been proven on both ends.

Source

What I would recommend instead is installing a Let's Encrypt certificate while waiting for your actual certificate to be issued. You can follow the steps on how to do that here:

https://www.digitalocean.com/community/tutorials/how-to-secure-apache-with-let-s-encrypt-on-ubuntu-16-04

Hope that this helps!
Regards,
Bobby

by Erika Heidi
This tutorial will show you how to set up a free TLS/SSL certificate from Let’s Encrypt on a Ubuntu 16.04 server running Apache as web server. TLS certificates are used within web servers to encrypt the traffic between server and client, providing extra security for users accessing your application.
Have another answer? Share your knowledge.