Redirect HTTP to HTTPS

On rare occasions, we see situations where your SSL certificate installation looks perfect but does not redirect the http:// traffic to https:// properly. It may leave you stuck on a white screen, not to be confused with the white screen of death due to improper WordPress setups.

To test that it’s NOT a WordPress problem, just open your index.php file and add echo ‘Hello”; exit(); and test your site. If you get the Hello on either the http or https version of your website, then it’s not a WordPress issue, it’s an HTTPS redirect issue. After troubleshooting, remember to remove the Hello and exit() function or your site won’t work anymore 😉

This redirect issue is a real pain because a lot of visitors don’t type out http or http into the address bar, they just type your domain and the dot-com, or dot-whatever and press Enter. That will likely take your visitor straight to the problematic http leaving them stuck at the white screen. If you have banged your head against the desk trying to figure this one out, join the club.

How To Fix It:

To fix this, open the following file with nano or your fav editor:

/etc/apache2/sites-enabled/yourDomain.com.conf

Look for ServerName www.yourDomain.com and just below it add…

Redirect permanent / https://www.yourDomain.com/

When you are down it should look like this

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

…what ever else was below this line, just leave that alone.
</VirtualHost>

example of altering the yourDomain.com.conf file.

That usually solves it for us and I hope it solves it for you! If you can’t hammer it out, just give us a call.