0

I found every combination on the net except of this one. How do I redirect all traffic in a generic way to the "http://www."?

So that happens:

domain.com --> http://www.domain.com
www.domain.com --> http://www.domain.com
https://domain.com/page --> http://www.domain.com/page

etc.

Thanks in advance for any help!

getimo
  • 25
  • 3

2 Answers2

0

This way

RewriteEngine on
RewriteCond %{HTTPS} ^on [OR]
RewriteCond %{HTTP_HOST} ^example\.com [NC]
RewriteRule ^(.*)$ http://www.example.com/$1 [R=301,L]
Panama Jack
  • 24,158
  • 10
  • 63
  • 95
0

So all you need to use is:

RewriteEngine On

#Force WWW on everything
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]

#Check to see if HTTPS, if so, make HTTP
RewriteCond %{HTTPS} on
RewriteRule ^ http://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

This will force WWW and HTTP on everything.

Joe
  • 4,877
  • 5
  • 30
  • 51
  • Thanks but `https://www.example.com` doesn't redirect to `http://www.example.com`. `https://example.com` redirects correctly to `http://www.example.com` – getimo Jun 27 '16 at 10:44