all
I want to redirect all requests to land on https://www URL, e.g.
case1: http://www.example.com --301--> https://www.example.com
case2: https://example.com --301--> https://www.example.com
case3: http://example.com --301--> https://www.example.com
Here I have my code in .htaccess file
RewriteCond %{HTTPS} off
RewriteRule .* https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule .* https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
It works fine in case 1 and 2. However when I have a http and non-www request (case3), it will require two 301 redirects to land on https://www
http://example.com
--301-->
https://example.com
--301-->
https://www.example.com
How can we force https and www with always just 1 301 redirect.
I am not very familiar with Apache and rewrite module. Help please!