title: Redirecting http link to https
body: <p>So Im redirecting an old url that uses HTTP protocol for SEO purposes. Problem is that I can't redirect it without an extra step that I made. In that step I wrote these three lines in htaccess file.</p>
  <pre><code>RewriteEngine On
  RewriteCond %{SERVER_PORT} 80
  RewriteRule ^(.*)$ https://www.example.com/$1 [R,L]
  </code></pre>
  <p>The problem is that there is an extra step in redirecting. The link is first redirected to HTTPS and then to the right redirected page. Can I eliminate the middle step when it firstly changes HTTP to HTTPS protocol.</p>
  <pre><code>RewriteEngine On
  RewriteCond %{SERVER_PORT} 80
  RewriteRule ^(.*)$ https://www.example.com/$1 [R,L]
  
  &lt;IfModule mod_rewrite.c&gt;
  RewriteEngine On
  RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
  RewriteBase /
  RewriteRule ^index\.php$ - [L]
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteRule . /index.php [L]
  &lt;/IfModule&gt;
  
  &lt;IfModule mod_rewrite.c&gt;
      RewriteEngine On
      RewriteBase /
      RewriteCond %{HTTPS} =on
      RewriteRule .* - [E=W3TC_SSL:_ssl]
      RewriteCond %{SERVER_PORT} =443
      RewriteRule .* - [E=W3TC_SSL:_ssl]
      RewriteCond %{HTTP:X-Forwarded-Proto} =https [NC]
      RewriteRule .* - [E=W3TC_SSL:_ssl]
      RewriteCond %{HTTP_COOKIE} w3tc_preview [NC]
      RewriteRule .* - [E=W3TC_PREVIEW:_preview]
      RewriteCond %{REQUEST_METHOD} !=POST
      RewriteCond %{QUERY_STRING} =&quot;&quot;
      RewriteCond %{HTTP_COOKIE} !(comment_author|wp\-postpass|w3tc_logged_out|wordpress_logged_in|wptouch_switch_toggle) [NC]
      RewriteCond %{REQUEST_URI} \/$
      RewriteCond &quot;%{DOCUMENT_ROOT}/wp-content/cache/page_enhanced/%{HTTP_HOST}/%{REQUEST_URI}/_index%{ENV:W3TC_SSL}%{ENV:W3TC_PREVIEW}.html&quot; -f
      RewriteRule .* &quot;/wp-content/cache/page_enhanced/%{HTTP_HOST}/%{REQUEST_URI}/_index%{ENV:W3TC_SSL}%{ENV:W3TC_PREVIEW}.html&quot; [L]
      RewriteCond %{REQUEST_METHOD} !=POST
      RewriteCond %{QUERY_STRING} =&quot;&quot;
      RewriteCond %{HTTP_COOKIE} !(comment_author|wp\-postpass|w3tc_logged_out|wordpress_logged_in|wptouch_switch_toggle) [NC]
      RewriteCond &quot;%{DOCUMENT_ROOT}/wp-content/cache/page_enhanced/%{HTTP_HOST}/%{REQUEST_URI}/_index%{ENV:W3TC_SSL}%{ENV:W3TC_PREVIEW}.xml&quot; -f
      RewriteRule .* &quot;/wp-content/cache/page_enhanced/%{HTTP_HOST}/%{REQUEST_URI}/_index%{ENV:W3TC_SSL}%{ENV:W3TC_PREVIEW}.xml&quot; [L]
  &lt;/IfModule&gt;
  </code></pre>
  <p>Pic of the steps:</p>
  <p><a href="https://i.stack.imgur.com/8h8Gh.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/8h8Gh.png" alt="enter image description here" /></a></p>