tags:

views:

185

answers:

1

Dear All,

I configure the Rewrite rule in Apache server. But it cannot rewrite the URL.

Think my main goal here is to 301-redirect ALL "non-www" to "www" for the HTTPS requests.

Rewritecond %{https} = on
RewriteCond %{HTTP_HOST} !^www\.domainname\.com$
RewriteRule ^(.*)$ https://www.domainname.com/$1 [R=301,L]
A: 

Try this rule:

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

That should work for both HTTP and HTTPS.

Gumbo