views:

30

answers:

1
RewriteCond %{HTTP_HOST} !^www.example.co.uk$ [NC] 
RewriteRule ^(.*)$ https://www.example.co.uk/$1 [R=301,QSA,L] 

thats for the www, but I cannot figure out in a one-pass way how to force the https too?

+1  A: 

Use the SERVER_PROTOCOL variable:

RewriteCond ${SERVER_PROTOCOL} !^https [NC]
Sjoerd
I think this is what I need to do, but perhaps it can be simplified?RewriteCond %{HTTP_HOST} !^www.example.co.uk$ [NC]RewriteRule ^(.*)$ https://www.example.co.uk/$1 [R=301,QSA,L]RewriteCond %{HTTPS} !=on [NC]RewriteRule ^(.*)$ https://www.example.co.uk/$1 [R=301,QSA,L]
boobyWomack