Forum Moderators: phranque
...this will work:
Will this function alone in .htaccess or does it need further support from other files?
Will this indeed take care of (redirect) any...
[env=ps:http]
RewriteCond %{HTTP_HOST} !^(www\.example\.com)?$ [OR]
RewriteCond %{HTTPS} off
RewriteRule ^(all-secure-pages-or-directories-here) https://www.example.com/$1 [R=301,L]
RewriteCond %{HTTP_HOST} !^(www\.example\.com)?$ [OR]
RewriteCond %{HTTPS} on
RewriteRule ^(all-NON-secure-pages-or-directories-here) http://www.example.com/$1 [R=301,L]
Since the two rules are mutually exclusive* you can put them in either order. Start with whichever form you have more of, secure or not. ("More of" means overall number of requests, not the raw number of files.) You're going to need redirects...
...maybe I should be thinking rel=canonical
If you only need to make sure users are directed to the correct pages from Google SERPs then a rel=canonical should suffice
A "rel-canonical" doesn't create a redirect; it's supposed to obviate the need for one because only one form gets indexed.