Forward HTTPS non-WWW to HTTPS WWW

#1
Hi,

I am having issues on my domain where all other url: example.org, www.example.org, both HTTP points to my https://www.example.org, but when I access the https://example.org, it does not redirect to the https://www.example.org.

I am using the Wordpress OpenLiteSpeed in DigitalOcean and have used most of the solutions in wordpress and OpenLite Speed Forum. I also tried using the plugin-Redirect and still not successful.

I managed to add this code in my .htaccess in /var/www/html as per suggested.

1587387875356.png
Any help is much appreciated.

Thanks
 
#3
Hi,

Eric. Thanks for the quick response. Yes I have. Every time I update my htaccess, i do a restart.

Also, if it helps, I have also tried these separately:

Code:
RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ https://www.%{HTTP_HOST}/$1 [R=301,L]
Code:
RewriteCond %{HTTP_HOST} ^yourdomain.com [NC]
RewriteRule ^(.*)$ http://www.yourdomain.com/$1 [L,R=301]
Code:
RewriteCond %{HTTPS} !^on$
RewriteRule (.*) https://www.website.co.uk/$1 [R,L]
Given that I swap my domain to those placeholders.
 
#4
This is what you need to do for your HTTPS redirect. If you're using Wordpress, make sure that you change the default URL to your site and dashboard to include HTTPS://WWW. YOURWEBSITE. If you don't do this you won't be able to access your Wordpress dashboard. Had the same problem and probably Litespeed need to include it by default when it comes to redirecting from non-HTTP WWW to HTTPS WWW

Then rewrite your .HTACCESS file with the following condition

Code:
RewriteCond %{HTTP:X-Forwarded-Proto} !^https$ [NC]
RewriteCond %{HTTPS} !^on$ [NC]
RewriteRule .* https://www.yourwebsite.com%{REQUEST_URI} [R=301,L,NE]
 
Top