I am trying to force redirect in the .htaccess but it only works partially.
When I enter http://domainName or domainName, it redirects to https://www.domainName/ as expected
However, if I enter http://domainName/commercial for example, it redirects to https://domainName/commercial instead of https://www.domainName/commercial
I tried different methods of the redirect rules, but all produces the same result:
Option 1
RewriteCond %{HTTP_HOST} ^domainName$ [NC]
RewriteRule ^(.*) https://www.domainName/$1 [R=301,L]
Option 2
RewriteCond !{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
RewriteCond %{HTTP_HOST} !^www.
RewriteRule ^(.*)$ https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
Option 3 (swapped the order of option 2)
RewriteCond %{HTTP_HOST} !^www.
RewriteRule ^(.*)$ https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
Expected: https://www.domainName/commercial
But Getting: https://domainName/comercial
6