I used info from this answer (https://stackoverflow.com/a/85867/3271766 - along with the contribution from Dave1010) to allow me to force a page to load securely (https://). This works beautifully!
Now, I want to do the opposite. When clicking a relative link (to a normal, non-secure page) from a secure page, I want to force that page to load non-securely (http://). I don't want to use absolute links to accomplish this. They need to stay relative. Instead, I'd rather use a piece of PHP code similar to what I used to force pages to load securely.
How can this be done? Thanks, in advance, for your help.
The code I used (in each page's head tags) to force pages to load securely is:
<?php
// WORKING: FORCE SECURE - Force page to load securely (http:// > https://)
if(empty($_SERVER["HTTPS"]) || $_SERVER["HTTPS"] !== "on")
{
header("Location: https://" . $_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"]);
exit();
}
?>
I tried the following, but it stops the page from loading altogether:
<?php
// NOT WORKING: FORCE NON-SECURE - Force page to break out of secure protocol (https:// > http://)
if(empty($_SERVER["HTTP"]) || $_SERVER["HTTP"] !== "on")
{
header("Location: http://" . $_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"]);
exit();
}
?>
Is there a way to modify this to make it work?
(By the way, in case anyone is wondering, I am doing this because a third-party sharing tool my client wants to use does not have a valid security certificate. Thus, portions of the sharing tool either do not load, or do not function. I have contacted the vendor repeatedly, but they have not responded. I have removed the tool from the secure pages only. However, my client wants to use this tool on all other pages, on which it works perfectly, so long as it is not accessed securely.) :-)
Regards, Jeremy