Force HTTPS - Route 'index.php' not found

I have realized if you force https using the following .htaccess file, you will get Route ‘index.php’ not found IF you access Custom files directly from an http://example.com/customlink

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^ index.php [QSA,L]
RewriteEngine On 
RewriteCond %{HTTPS} off 
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
  1. Remove the duplicate “RewriteEngine On”,
  2. Review your code (.*) https://%{HTTP_HOST}%{REQUEST_URI}, the regular expression may be wrong and is not used. (You may google “Force HTTPS with the .htaccess File” to find more info.)