Redirect issue from HTTPS Non-WWW to WWW

  • Posted April 20, 2020
  • DNS

I’m having issues with my domain pointing to my Wordpress Openlite Server. All except is not pointing to my site (all http points to the correct secure domain.

I know that this has been asked a lot and tried most of the suggestions including overwriting my .htaccess. I even used Redirect plugin but with no avail.

The latest code I used for the htcaccess is this:

RewriteEngine on
RewriteCond %{HTTPS} !on [OR]
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule (.*){REQUEST_URI} [L,R=301]

It still wont redirect the correct one and this also causes issues on my other pages not redirecting the correct url. I also saw this:

RewriteCond %{HTTP_HOST} ^www\.your-domain\.com
RewriteRule (.*)$1 [R=301,L]

But based on the rewrite Cond, it could only accommodate HTTP and not HTTPS.

Any help is much appreciated.



Submit an answer
You can type!ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Hello, @jonasalmocera

The .htaccess rules can sometimes be trickier and you can spend hours in order to find the one that is suitable with your needs. If you want to forward all the traffic to the www version of your domain name can you please try with using this code:

RewriteEngine On
RewriteCond %{HTTP:X-Forwarded-Proto} !https
RewriteRule ^(.*)$$1 [R=301,L]

An alternative one will be:

RewriteEngine On
RewriteCond %{HTTPS} !on
RewriteRule ^(.*)$$1 [R=301,L]

Hope this helps!

Let me know how it goes.

Regards, Alex