2

I've the following redirect

RewriteCond %{HTTP_HOST} !^www\. 
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L] 
RewriteCond %{HTTPS} !on
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

How can I redirect non WWW https to WWW?

The htaccess is located in the public_html folder

Dharman
  • 30,962
  • 25
  • 85
  • 135
Overnet
  • 965
  • 3
  • 12
  • 20

2 Answers2

4

You can use the following :

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

This will redirect

to

Amit Verma
  • 40,709
  • 21
  • 93
  • 115
2

I'm using this on a Joomla site and it redirects everything to https://www I can't see this solution anywhere else so thought I'd share it

RewriteCond %{HTTP_HOST} ^domainname\.co.uk [NC]
RewriteRule ^(.*)$ https://www.domainname.co.uk/$1 [R=301,L]
Jennie
  • 21
  • 1