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 do I parse html files as shtml?

Create an .htaccess file in the directory needed and add the following: AddHandler...

My site was hacked

This typically occurs when you are running a script/app on your website which is out-dated and...

What are some tools are available to optimize my website?

There are many great tools to optimize your website. There is an optimize tool in your hosting...

“Not Secure” Web Error

In this day and age browsers now default to using https:// instead of http://. We make SSL...

Adding HTML to Site Builder

When adding HTML code/source in site builders be sure you are in HTML mode. There is often a...