0
votes

I'm facing a very annoying issue for a long time, perhaps someone could shed a light on this matter...

All my Wordpress websites at shared enrivonment at Hostinger all have the same bug: Random redirects to HTTPS

Sometimes it tries to load all resources through HTTPS - seems randomly.

Most of the time though, the redirect occurs on wp-admin, while saving posts, navigating, etc.

I already added this to .htaccess, for example:

RewriteCond %{HTTPS} on 
RewriteRule (.*) http://%{HTTP_HOST}%{REQUEST_URI}

These are default wordpress installations with no settings changed, it's really a bug, Hostinger already acknolwedged that. They said they would fix it, but it's been more than 6 months.

The certificate is issued to *.main-hosting.eu and the error is NET::ERR_CERT_AUTHORITY_INVALID

How can I redirect ALL HTTPS requests to HTTP? How can I solve this bug?

-- Edit --

I confirmed it's a server-side bug, creating a simple debug.php with the following code: http://pastebin.com/n8PekA6d - the result is this: http://pastebin.com/t70nkTyj

2
You cannot redirect the HTTPS-requests to HTTP, because they never arrive at the server (the SSL error happens before any request gets made). I'm afraid you're looking in the wrong direction. - Daan Meijer
@DaanMeijer There's nothing I can do in a shared hosting environment? I'm at Hostinger's hands? - Lucas Bustamante
Well, I didn't say that. I feel it's very strange for a server configuration to randomly redirect you to SSL. My intuition is that the redirects come from within PHP, somewhere. However, if you are sure that it's not coming from PHP, and it depends on the hoster, there's very little you can do save for finding another hoster :( - Daan Meijer
It only happens with Wordpress websites. I have around 40 of them hosted there, and one or two custom MVC I made myself. Do you have any idea of how can I find where it might be redirecting to HTTPS in the giant mess of Wordpress code? - Lucas Bustamante
Usually, any redirects get done by wp_redirect(...). It's defined in wp-includes/pluggable.php, around line 1143. Here you can experiment with var_dump($location); debug_print_backtrace(); die(); to examine the call path that got you there :) - Daan Meijer

2 Answers

1
votes

I watched your video. Although I would normally recommend enabling https, in this case you might be off better with:

$_SERVER['REQUEST_SCHEME'] = 'http';
$_SERVER['SERVER_PORT'] = 80; //thanks to Lucas Bustamante

in your wp-config.php. Hope that helps :)

0
votes

Thanks, Lucas 4 years down that line of code still works and helped out, Hostinger still has that bug sorry to report.

The graphical representation will manifest as the "FORCE HTTPS" toggle will become inactive