redirect non-www to www while preserving protocol

Posted by Waleed Hamra on Pro Webmasters See other posts from Pro Webmasters or by Waleed Hamra
Published on 2012-11-22T16:02:36Z Indexed on 2012/11/22 17:11 UTC
Read the original article Hit count: 306

Filed under:
|
|
|
|

I am aware of the fact that there are tons of questions in this section and in server fault dealing with redirections from non-www to www URLs. But I couldn't find one dealing with this issue while preserving protocol. I am no mod-rewrite expert, and my code is just copy/pasted... here's what i have:

RewriteCond %{HTTP_HOST} ^domain.tld$ [NC]
RewriteRule ^(.*)$ http://www.domain.tld$1 [R=301,L]

So now http://domain.tld and https://domain.tld are forwarded to http://domain.tld

How do i make it so that https stays on https while http stays on http?

© Pro Webmasters or respective owner

Related posts about seo

Related posts about mod-rewrite