title: redirect 301 to / if url contains index.php
body: <p>I have a blog in laravel 5.8 and I want to redirect 301 to / it there is index.php in the url.</p>
  
  <p>My .htaccess is this</p>
  
  <pre><code>&lt;IfModule mod_rewrite.c&gt;
      &lt;IfModule mod_negotiation.c&gt;
          Options -MultiViews -Indexes
      &lt;/IfModule&gt;
  
      RewriteEngine On
  
      # Handle www + https
      RewriteCond %{HTTPS} off [OR]
      RewriteCond %{HTTP_HOST} !^www\. [NC]
      RewriteRule .* https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
  
      # Redirect if index.php is in the URL
      RewriteCond %{THE_REQUEST} ^GET.*index\.php [NC]
      RewriteRule (.*?)index\.php/*(.*) /$1$2 [R=301,NE,L]
  
      # Handle Authorization Header
      RewriteCond %{HTTP:Authorization} .
      RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
  
      # Redirect Trailing Slashes If Not A Folder...
      RewriteCond %{REQUEST_FILENAME} !-d
      RewriteCond %{REQUEST_URI} (.+)/$
      RewriteRule ^ %1 [L,R=301]
  
      # Handle Front Controller...
      RewriteCond %{REQUEST_FILENAME} !-d
      RewriteCond %{REQUEST_FILENAME} !-f
      RewriteRule ^ index.php [L]
  &lt;/IfModule&gt;
  </code></pre>
  
  <p>I have tried this approach:</p>
  
  <pre><code>    # Redirect if index.php is in the URL
      RewriteCond %{THE_REQUEST} ^GET.*index\.php [NC]
      RewriteRule (.*?)index\.php/*(.*) /$1$2 [R=301,NE,L]
  </code></pre>
  
  <p>but the problem is IF there is an url like this one that contains (?get_params)</p>
  
  <pre><code>htts://www.example.com/index.php?test
  </code></pre>
  
  <p>it will redirect 301 to /?test</p>
  
  <p>How can I change the rule to redirect 301 to / (without any ? params) if the url contains index.php ?</p>