title: Mod-rewrite : Force SSL & remove extension - 50% success on same scenario
body: <p>I am having some very weird issues with my .htaccess rewrites.</p>
  
  <p>For 2 of the 4 pages I have tested , the rewrites work , the other two fail for some reason and redirect to the main page (as expected of my error rewrite)</p>
  
  <p>The tests I am doing are making sure all files with .html have their extensions removed as well as ensuring a https connection.</p>
  
  <p>I test them individually and as a pair (rewrite/redirect to https as well as remove .html). They only fail when I try to rewrite both conditions</p>
  
  <p>Sample URL:</p>
  
  <blockquote>
    <p><a href="http://www.websitename.co/about.html" rel="nofollow noreferrer">http://www.websitename.co/about.html</a></p>
  </blockquote>
  
  <p>Expected:</p>
  
  <blockquote>
    <p><a href="https://www.websitename.co/about" rel="nofollow noreferrer">https://www.websitename.co/about</a></p>
  </blockquote>
  
  <p>Works for "index.html" , but not "about.html" for example.
  All pages are simple, one-word-named pages , no special characters etc.</p>
  
  <p>I repeated the test in the same fashion for all 4 pages , but for 2 pages , they work , for the other 2 ,they dont.</p>
  
  <p>Some help would be appreciated, thanks!</p>
  
  <pre><code>RewriteEngine On
  
  DirectoryIndex home.html home.php index.php index.html index.htm
  
  ErrorDocument 404 www.WEBSITENAME.co
  
  #Force ssl
  RewriteCond %{HTTPS} !=on
  RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [R=301]
  
  #Ecwid rewrite
  RewriteRule ^shop/.*$ shop [L]
  
  #example.com/page will display the contents of example.com/page.html
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteCond %{REQUEST_FILENAME}.html -f
  RewriteRule ^(.+)$ $1.html [L,QSA]
  
  #301 from example.com/page.html to example.com/page
  RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /.*\.html\ HTTP/
  RewriteRule ^(.*)\.html$ /$1 [R=301,L]
  </code></pre>