Overnet
Overnet

Reputation: 983

Redirect NON-www to www for https

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

Upvotes: 2

Views: 11257

Answers (2)

Jennie
Jennie

Reputation: 21

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]

Upvotes: 2

Amit Verma
Amit Verma

Reputation: 41249

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

Upvotes: 4

Related Questions