How to Re-Direct non WWW, non HTTPS to WWW, HTTPS without Multiple Re-Directs?

I hope you can help with this htaccess issue please? I basically have the htaccess rules working apart from in one scenario. This is the case where a user visits the site on a non HTTPS and non WWW links.


  1. User visits on http/non-WWW URL
  2. User is redirected initially to the http/WWW URL
  3. User is then redirected to

You can see the behaviour here:

All other scenarios work fine.

I want to try to remove the 2nd redirect from the sequence so it behaves like this:

User visits on http and is immediately redirected to the https/www version without the 2nd step (if that makes sense?)

The current scenario causes multiple re-directs, which I understand is a bad approach from an SEO perspective.

This is my htaccess redirect rule:

RewriteEngine On
# This will enable the Rewrite capabilities

RewriteCond %{HTTPS} !=on
# This checks to make sure the connection is not already HTTPS

RewriteRule ^/?(.*) https://%{SERVER_NAME}/$1 [L,R=301]
# This rule will redirect users from their original location, to the same location but using HTTPS.
# The leading slash is made optional so that this will work either in httpd.conf
# or .htaccess context

Source: .htaccess

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.