Here is in PHP as you wish: (answer edited by @Bacco)
<?php
function ForceHTTP() {
if ($_SERVER['HTTPS'] == "on") {
$url = $_SERVER['SERVER_NAME'];
$new_url = "http://" . $url . $_SERVER['REQUEST_URI'];
header("Location: $new_url");
exit;
}
}
?>
Do not forget to "call" the function:
<?php ForceHTTP(); ?>
Or with .htaccess
to always open in HTTP://
RewriteEngine On
RewriteCond %{HTTPS} on
RewriteRule (.*) http://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
Or with .htaccess
to always open in HTTPS://
(which is how I use it on my site):
RewriteCond %{HTTPS} !=on
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]