0

I've searched for a solution of my problem on SO but none of the answers worked for me.

This is what i want to achieve:

Redirect all

http://example.com -> https://example.com
http://www.example.com -> https://example.com
https://www.example.com -> https://example.com

Basically i want that whatever form of the domain is accessed to be redirected to non-WWW https (https://example.com)

m3tsys
  • 3,939
  • 6
  • 31
  • 45

1 Answers1

0

You can use in your .htaccess:

RewriteCond %{HTTP_HOST} ^www\.(.+) [NC]
RewriteRule ^ https://%1%{REQUEST_URI} [NE,L,R=301]
RewriteCond %{HTTPS} off
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [NE,L,R=301]
Croises
  • 18,570
  • 4
  • 30
  • 47
  • same old problem: `ERR_TOO_MANY_REDIRECTS` – m3tsys Sep 13 '15 at 18:20
  • Not with my code, it's in your config or htaccess with other rules – Croises Sep 13 '15 at 18:22
  • it is the only code in the htaccess. And here is what the header looks like now: `HTTP/1.1 400 Bad Request => Server => cloudflare-nginx Date => Sun, 13 Sep 2015 18:29:47 GMT Content-Type => text/html Content-Length => 177 Connection => close` – m3tsys Sep 13 '15 at 18:28
  • Problem with cloudflare configuration ? As I said, I think it's a problem with the configration. – Croises Sep 13 '15 at 20:43