Redirect

Nginx

IIS

Redirect a site to HTTPS using .htaccess file

RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301,NE]

Redirect a web site to SSL using Apache Virtual Host

ServerName www.yourdomain.com 
Redirect permanent / https://www.yourdomain.com/

OR

RewriteEngine on
RewriteCond %{SERVER_NAME} =yourdomain.com [OR]
RewriteCond %{SERVER_NAME} =www.yourdomain.com
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]

Redirect a Site to HTTPS using PHP

if ($_SERVER["HTTPS"] != "on") {
    header("HTTP/1.1 301 Moved Permanently"); 
    header("Location: https://www.yourdomain.com");
}

Redirect www to non-www URL

RewriteEngine On
RewriteCond %{HTTP_HOST} ^www.yourdomain.com [NC]
RewriteRule ^(.*)$ https://yourdomain.com/$1 [L,R=301]
Need help with Linux Server or WordPress? We can help!

Leave a Reply

Your email address will not be published. Required fields are marked *