apache force https code example

Example 1: apache redirect http to https


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

Example 2: redirect http to https all domains vhost

RewriteEngine On
RewriteRule ^(.*)$ https://%{HTTP_HOST}$1 [R=301,L]

Example 3: 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]

Example 4: redirect http to https apache2 ubuntu 20.04

HTTP Redirection

Tags:

Misc Example