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

Why does it show the Ultra Web Hosting home page when I go to my site?

There are several reasons for this. Ensure you do not have https at the beginning of your...

htaccess referral redirect

It is often useful to redirect a visitor to a page based on the referring website. There are...

How do I customize error messages for my site?

Within control panel select Custom Error Pages. Select the error code link and place whatever...

vBulletin fsockopen() [function.fsockopen]: unable to connect

When setting up mail in vBulletin be sure you are using localhost for the mail server along with...

Why do I have references to robots txt in my web stat programs?

Many search engines will look for a robots.txt file before spidering your sites content. The...