I can't seem to get myredirects to work as desired. My objectives are:
- Redirect http://example.com to https://www.example.com
- Redirect http://www.example.com to https://www.example.com
Objective 1 has aleady been achieved, but the problem is redirection http://www.example.com to https://www.example.com, and its actually resulting to a 404 error. I used Ryte to identify the issue which is as below:
https://enmowe.com/ (403) is not reachable
http://enmowe.com/ (301) is forwarding to https://www.enmowe.com/ (200)
https://www.enmowe.com/ (200) is available
http://www.enmowe.com/ (404) is not reachable
I have tried the following in my Apache VirtualHost:
Method 1.
<If "%{HTTP_HOST} != 'www.enmowe.com'">
Redirect "/" "https://www.%{HTTP_HOST}/$1"
</If>
<If "%{SERVER_PROTOCOL} != 'HTTPS'">
Redirect "/" "https://www.%{HTTP_HOST}/$1"
</If>
Method 2.
RewriteEngine On
RewriteCond %{HTTP_HOST} !^(www.\.enmowe\.com)?$
RewriteRule (.*) https://www.enmowe.com/$1 [R=301,L,NC]
Method 3.
RewriteEngine on
RewriteCond %{SERVER_NAME} =enmowe.com
RewriteRule ^ https://www.%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
Kinda feel lost right now