Redirect http to https and www

To forward a website to use both www. and https:// use the following in an .htaccess file:

RewriteCond %{HTTPS} off
RewriteRule .* https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule .* https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]


If that code doesn't work please try the following...


RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule ^(.*) https://www.%{SERVER_NAME}%{REQUEST_URI} [L,R=301]
RewriteCond %{HTTPS} off
RewriteRule ^(.*) https://%{SERVER_NAME}%{REQUEST_URI} [L,R=301]

  • 4 Users Found This Useful

Was this answer helpful?

Related Articles

How to create a temporary 302 redirect via htaccess

An easy way to create a temporary redirect from one page to another web page is to use the 302...

Reseller: Unable to find an IP address in when creating an account

When creating accounts be sure to select a package in the package field. You can create a package...

Domain Slamming - Beware

There are several companies out there using a predatory practice of attempting to have you renew...

Redirect Internet Explorer visitors to a supported browsers page

Redirect users of Internet Explorer to a supported browsers page or any other page.  To do this,...

Creating a Form Button

Sometimes all you need is a simple button. The following pages are pretty useful tools for...