How do I use .htaccess to always redirect from HTTP to HTTPS? [duplicate]

I wouldn't use mod_rewrite, you can achieve it simply with mod_alias:

Redirect permanent / https://other-site

Where 'other-site' is the hostname you want to redirect to, ommitting the www. prefix that you do not want.


There are so many solutions:

RewriteEngine On
RewriteCond %{HTTPS} !^on$
RewriteRule (.*) https://yourdomain/$1 [R,L]