I have a client who has an http SEO'ed wordpress site, with https AdWords static html landing pages (I know - don't ask). They want to 301 all non-www to www. I tried the following htaccess code:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^example.com
RewriteRule (.*) http://www.example.com/$1 [R=301,L]
This works great for getting all URLs redirected to www from non-www. However it also changes all https URLs to http.
How can I get it so that all non-www redirect to www, but http and https are NOT affected.
For example:
http://example.com/seo-page -> http://www.example.com/seo-page
and
https://example.com/ppc-page -> https://www.example.com/ppc-page
Thanks
EDT: Existing .htaccess is:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteRule .* - [E=CANONICAL:http://%{HTTP_HOST}%{REQUEST_URI},NE]
RewriteCond %{HTTPS} =on
RewriteRule .* - [E=CANONICAL:https://%{HTTP_HOST}%{REQUEST_URI},NE]
</IfModule>
https://...explicitly. - CBroe