Redirect http to https and www

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:

How Can I Redirect HTTP to HTTPS

This article has been consolidated into our How Can I Redirect HTTP to HTTPS guide for easier reference.

  • 4 Users Found This Useful

Was this answer helpful?

Related Articles

htaccess referral redirect

htaccess & Redirects | Updated 2026 You can use .htaccess to redirect visitors based on...

Nginx and htaccess Redirect Issues

htaccess & Redirects | Updated March 2026 If your .htaccess redirects aren't working for...

301 Redirect

Updated 2026 Quick Answer A 301 redirect permanently sends visitors and search engines...

Redirecting non-www to www with htaccess

htaccess & Redirects | Updated 2026 Choosing between www and non-www for your domain is a...

What are these htaccess files that keep popping up?

htaccess & Redirects | Updated 2026 If you keep finding .htaccess files appearing in your...



Save 30% on web hosting - Use coupon code Hosting30