I've looked everywhere and tried the top results from Stack Exchange but none of the solutions actually solve this problem.
If user types:
example.com/secure
http://example.com/secure
it redirects to https://www.example.com/secure <---GOOD!
but if the user types:
http://www.example.com/secure
www.example.com/secure
https://example.com/secure
it redirects to http://www.example.com/secure <---not good
I need to force both https:// and www. regardless of how the user types it.
Here are the solutions I've tried:
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]
and
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]
Please, can someone suggest an ultimate solution for this?
Aucun commentaire:
Enregistrer un commentaire