I have a Drupal site (apache server) that I've converted to 100% to https.
I've been using a redirection checker and have found that:
http://example.com
301 redirects to:
http://www.example.com
that 301 redirects to:
https://www.example.com
The code below is from my .htaccess file.
I was thinking that if my non-www to www 301 redirect instead redirected to https://www.example.com that I could cut out one redirect with the above scenario.
The problem is I'm in way over my head on this and don't understand the syntax used.
Is there a way where this code be altered to do what I've stated above?
# Note: The following set of directives is standard Drupal .htacess coding --
# Set "protossl" to "s" if we were accessed via [
....] This is used later
# if you enable "www." stripping or enforcement, in order to ensure that
# you don't bounce between http and https.
RewriteRule ^ - [E=protossl]
RewriteCond %{HTTPS} on
RewriteRule ^ - [E=protossl:s]
# Note: The following set of directives is standard Drupal .htacess coding --
# If your site can be accessed both with and without the 'www.' prefix, you
# can use one of the following settings to redirect users to your preferred
# URL, either WITH or WITHOUT the 'www.' prefix. Choose ONLY one option:
#
# To redirect all users to access the site WITH the 'www.' prefix,
# (http://example.com/... will be redirected to http://www.example.com/...)
# uncomment the following:
RewriteCond %{HTTP_HOST} .
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule ^ http%{ENV:protossl}://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
# Note: "My lines" added for http to https:
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https
://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
[edited by: phranque at 4:19 am (utc) on Oct 3, 2016]
[edit reason] unlinked url pattern for clarity [/edit]