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

Show longer file names in directory/folder index

Updated 2026 Quick Answer To show longer file names in Apache's directory listing...

htaccess pcfg_openfile: unable to check htaccess file, ensure it is readable

htaccess & Redirects | Updated March 2026 The "pcfg_openfile: unable to check htaccess...

Nginx and htaccess Redirect Issues

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

Create a 410 Redirect for Missing Files

htaccess & Redirects | Updated 2026 A 410 (Gone) status code tells search engines that a...

How to Create a Temporary 302 Redirect via htaccess

htaccess & Redirects | Updated March 2026 A 302 redirect sends visitors (and search...



Save 30% on web hosting - Use coupon code Hosting30