Redirect site https to http

7

I currently have a site where you use an SSL certificate, as the certificate has expired and needs to be renewed, SSL error occurs on any browser, making it impossible for users to visit.

I would like to redirect traffic https:// to http:// using .htaccess .

    
asked by anonymous 11.05.2014 / 19:28

2 answers

7

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]
    
11.05.2014 / 20:51
4

Try it like this, I think it solves your problem. Add these lines to your .htaccess:

RewriteEngine On
RewriteCond %{HTTPS} on
RewriteRule (.*) http://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
    
11.05.2014 / 20:27