htaccess redirection https code example
Example 1: .htaccess redirect to https
<IfModule mod_rewrite.c>
....
....
# Redirect To HTTPS
RewriteCond %{HTTPS} off [OR]
RewriteCond %{HTTP_HOST} ^www\. [NC]
RewriteRule ^ https://example.com%{REQUEST_URI} [L,NE,R=301]
...
...
</IfModule>
Example 2: redirect htaccess http to https
RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://www.yourdomain.com/$1 [R,L]