I am modifying the .htacess. I tried changing https://mydomain.com to https://www.mydomain.com with the code below. Which failed.
# REDIRECT HTTPS:// TO HTTPS://WWW.
RewriteCond %{HTTPS} on
RewriteCond %{HTTP_HOST} ^my___domain\.com$ [NC]
RewriteRule ^(.*)$ http://www.my___domain.com/$1 [R=301,L]
What am I doing wrong?
As a note:
If this helps, to redirect both the IP and the original 3_$ (_">http://my3_$.com) to _">http://www.3__$.com I used these codes in the beginning, which worked.
# REDIRECT IP TO WWW.
RewriteCond %{HTTP_HOST} ^xxx\.xxx\.xxx\.xxx
RewriteRule (.*) http://www.my___domain.com/$1 [R=301,L]
# REDIRECT HTTP:// TO HTTP://WWW.
RewriteCond %{HTTP_HOST} ^my___domain\.com$ [NC]
RewriteRule ^(.*)$ http://www.my___domain.com/$1 [R=301,L]
I am trying to redirect the https:// because after modifying the two above successfully, I was unable to log in, as those were https:// pages.
Thank you
Instead of http://www.___.com/$1
, use //www.___.com/$1
. It will use http or https, whichever was used in the original request. Currently, you're forcing http, which seems to be the opposite of what you want.
I used this rewrite for redirect from http
to https
:
RewriteCond %{SERVER_PORT} ^80$
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
I guess in Your case adding something like this would do the job:
RewriteCond %{HTTP_HOST} ^domain\.com$
RewriteRule ^(.*)$ https://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
Hmm?