Redirect to https://www.example.com
I am currently using http://example.com but I want to redirect everything to http s : // WWW .example.com
I read a few threads here and tried quite a few solutions for this, but nothing worked for me.
My last try:
RewriteCond %{HTTP:X-Forwarded-Proto} !https
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]
When i use this code i can see it: enter image description here
But it also gives me this message:
The page is not redirecting as expected. Firefox discovered that the server redirects the request to this address in a way that never ends.
Can you help me?
source to share
You should try another solution like redirect.center , it's easier. Just configure DNS like this:
example.com A 54.84.55.102
redirect.example.com CNAME www.example.com.opts-https.opts-uri.redirect.center
Done!
source to share
It seems to me that you are also trying to force www. You can do it using this in your .htaccess
:
RewriteCond %{HTTP_HOST} !^www\. [NC,OR]
RewriteCond %{HTTPS} !=on
RewriteRule ^.*$ https://%{HTTP_HOST}%{REQUEST_URI} [R,L]
Place this rule at the beginning of your file .htaccess
and make sure you clear the cache before you tested it.
source to share