Redirect non-www to www and https using Redirect permanent


I'm trying to redirect everything from non-www to www and using https, for example: to
www.example to

I'm doing the changes in Configuration / Virtual Hosts / Rewrite

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

However, I want to use Redirect permanent
So I tried:
Redirect permanent /

Unfortunately, I got redirected you too many times.

I read and it seems it might be a bug, is there a way to use Redirect permanent in Configuration / Virtual Hosts / Rewrite to make it work?

Thank you!


if you redirect to other domain,
Redirect permanent /
it'll work well.

however, if you redirect to same domain, it'll cause infinite redirect loop as you've experienced.
since it just redirect to itself.

to user Redirect correctly, you have to set source URI different with target URI.
Redirect permanent /abc
will work as expected