Take the 2-minute tour ×
Webmasters Stack Exchange is a question and answer site for pro webmasters. It's 100% free, no registration required.

I am aware of the fact that there are tons of questions in this section and in server fault dealing with re-directions 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?

share|improve this question

1 Answer 1

up vote 1 down vote accepted

Just a little information. Best practices indicate that trafic from HTTP has to be redirected to HTTPS. If your site is reachable on HTTPS, no more need to HTTP.

I think you can associate no-www redirection to www with HTTP redirection to HTTPS.

Moreover, be careful of duplicate content if your site is reachable with HTTP and HTTPS.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.