0

How would I redirect my sub domain to https with .htaccess? I've tried to do this:

RewriteCond %{HTTP_HOST} ^sub\.example\.com$ [NC]
RewriteCond %{HTTPS} off
RewriteRule ^ https://sub.example.com%{REQUEST_URI} [R=301,L,NE]

But it didn't work I just got a cloudflare error. I've also tried this:

RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]

and it didn't work also just got the same cloudflare error

  • Possible duplicate of [Force SSL/https using .htaccess and mod\_rewrite](http://stackoverflow.com/questions/4398951/force-ssl-https-using-htaccess-and-mod-rewrite) – Dez Oct 23 '16 at 14:11
  • @Dez I just said that `RewriteEngine On RewriteCond %{HTTPS} off RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]` didn't work.... Read the question will ya? – Katherine Foster Oct 23 '16 at 14:12
  • In that question there is an answer for Cloudfare users. So I did read the question. – Dez Oct 23 '16 at 14:20
  • @Dez Just tried that and still get a error 526 from Cloudflare – Katherine Foster Oct 23 '16 at 14:23
  • If your are using cloudflare an want to "force" all urls https://support.cloudflare.com/hc/en-us/articles/200170536-How-do-I-redirect-all-visitors-to-HTTPS-SSL- – Bandi Oct 23 '16 at 20:20

0 Answers0