Updated 2026
Quick Answer
To redirect HTTP to HTTPS and non-www to www (or vice versa), add this to your .htaccess file:
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
For the complete guide:
This article has been consolidated into our How Can I Redirect HTTP to HTTPS guide for easier reference.
