Aqui está em PHP como você deseja: ( resposta editada por @Bacco)
<?php
function ForceHTTP() {
if ($_SERVER['HTTPS'] == "on") {
$url = $_SERVER['SERVER_NAME'];
$new_url = "http://" . $url . $_SERVER['REQUEST_URI'];
header("Location: $new_url");
exit;
}
}
?>
Não esqueça de "chamar" a função:
<?php ForceHTTP(); ?>
Ou com .htaccess
para abrir sempre em HTTP://
RewriteEngine On
RewriteCond %{HTTPS} on
RewriteRule (.*) http://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
Ou com .htaccess
para abrir sempre em HTTPS://
(que é como eu utilizo em meu site):
RewriteCond %{HTTPS} !=on
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
mod_rewrite
está habilitado.