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]

  • 0 Users Found This Useful

Was this answer helpful?

Related Articles

https:// with Weebly

To enable and force https:// with your Weebly website, be sure to go into your editor area,...

Is it possible to make a cron to backup my database at specific times?

Yes, this can be very useful for forum/message board sites with large databases. In your control...

What is the location of curl?

Curl is located @ /usr/bin/curl

What is a virtual Domain?

A virtual domain is the base URL of the domain name. Examples include yourdomain.com, and...

Add Flash Chat to your Website

We ran into this website recently which allows you to easily insert a flash chat room into your...