How To Redirect HTTPS To HTTP Or HTTP To HTTPS From Hosting24 Hosting

I am using Hosting24 Hosting, How can I redirect https to http url or http to https url

Here are some methods you can redirect https to http or http to https url for your Hosting24 Hosting

.htaccess

http to https

RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://www.example.com/$1 [R=301,L]

https to http

RewriteEngine On
RewriteCond %{SERVER_PORT} 443
RewriteRule ^(.*)$ http://www.example.com/$1 [R=301,L]

PHP

http to https

if($_SERVER["HTTPS"] != "on"){
    $host = $_SERVER['HTTP_HOST'];
    $request_uri = $_SERVER['REQUEST_URI'];
    $new_url = "https://" . $host . $request_uri;
    header( "HTTP/1.1 301 Moved Permanently" );
    header( "Location: $new_url" );
    exit;
}

https to http

if($_SERVER["HTTPS"] == "on"){
    $host = $_SERVER['HTTP_HOST'];
    $request_uri = $_SERVER['REQUEST_URI'];
    $new_url = "http://" . $host . $request_uri;
    header( "HTTP/1.1 301 Moved Permanently" );
    header( "Location: $new_url" );
    exit;
}

cPanel

http to https

Home >> Domains >> Redirects >> Add a redirect

0 0 votes
Article Rating
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments