htaccess for https redirect code example
Example 1: redirect http to https htaccess
RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteRule ^(.*)$ https:
Example 2: .htaccess redirect to https
<IfModule mod_rewrite.c>
....
....
RewriteCond %{HTTPS} off [OR]
RewriteCond %{HTTP_HOST} ^www\. [NC]
RewriteRule ^ https:
...
...
</IfModule>
Example 3: redirect htaccess http to https
RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https:
Example 4: https and www htaccess redirecr
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule .* https:
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule .* https:
Example 5: .htaccess redirect to https
RewriteEngine On RewriteCond %{SERVER_PORT} 80 RewriteRule ^(.*)$ https: