Answers for "how to redirect www to https"

0

redirect www to non www

RewriteEngine On
RewriteCond %{HTTP_HOST} ^www.yourdomain.com [NC]
RewriteRule ^(.*)$ http://yourdomain.com/$1 [L,R=301]
Posted by: Guest on May-29-2020
1

how to redirect http to https

RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
Posted by: Guest on July-02-2020
0

redirect http non www to https www

RewriteEngine On

RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule ^(.*)$ http://www.example.com/$1 [L,R=301]

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

# If this does not work:
RewriteEngine On

RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule ^(.*)$ http://www.example.com/$1 [L,R=301]

RewriteCond %{SERVER_PORT} !^443$
RewriteRule ^(.*)$ https://www.example.com/$1 [L,R=301]
Posted by: Guest on July-17-2020
0

how to redirect http to https

//PUT THIS IN .htaccess

RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} !^gymstatistics\.altervista\.org [NC,OR]
RewriteCond %{HTTP:CF-Visitor} '"scheme":"http"'
RewriteRule ^ https://gymstatistics.altervista.org%{REQUEST_URI} [NE,R=301,L]
Posted by: Guest on April-13-2020
0

redirect https

if ($_SERVER['HTTPS'] != "on") 
{
    $url = "https://". $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI'];
    header("Location: $url");
    exit;
}
Posted by: Guest on November-07-2020

Code answers related to "how to redirect www to https"

Browse Popular Code Answers by Language