Reputation: 99
When I try to redirect with or without www (example.com, www.example.com) To https://www.example.com, I am getting "The page isn’t redirecting properly" Error Message.
RewriteEngine on
RewriteCond %{HTTP_HOST} ^www\.example\.com$
RewriteRule ^(.*)$ "https\:\/\/example\.com\/$1" [R=301,L]
I tied below code also
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://www.example.com%{REQUEST_URI}
But when i try to redirect without www To https://www.example.com is working fine.
I need to redirect with or without www example.com To https://www.example.com
Upvotes: 0
Views: 104
Reputation: 99
Below code is redirecting (with or without www).example.com to https://www.example.com
RewriteEngine on
RewriteCond %{HTTP_HOST} ^(www\.)?(example.com)$
RewriteCond %{HTTP:X-Forwarded-Proto} !https [NC]
RewriteCond %{HTTPS} off
RewriteRule (.*) https://www.example.com/$1 [R=302,L]
Upvotes: 0