.htaccess - apache server- how to redirect http to https -


i have tried using mod_rewrite in .htaccess file code doesn't work, gives me error "too many redirects"

rewriteengine on rewritecond %{https} off rewriterule (.*) https://%{http_host}%{request_uri} 

any appreciated

if you're using cloudflare or aws or similar loadbalances or internally routes requests you, you'll need check %{http:x-forwarded-proto} header instead of %{https} variable.

rewriteengine on rewritecond %{http:x-forwarded-proto} !https rewritecond %{https} off rewriterule ^ https://%{http_host}%{request_uri} [l] 

Comments