title: htaccess - remove “index.php” from URL and redirect with exclusion
body: <p>I have read a lot of answers on this site, but didn't find a working example. Therefore, I decided to ask my question.</p>
  
  <p>How can I make a redirect from a file (index.php(.htm /.html / etc.) with exclusion?</p>
  
  <p>For example, I have a link #1: "/dir1/some-text_index.php" and link #2: /dir1/index.php.
  What rule should be set to link #1 - redirect doesn't happen, and link #2 occurred redirect, ie:</p>
  
  <pre><code>/dir1/some-text_index.php -&gt; /dir1/some-text_index.php - nothing to do
  /dir1/index.php -&gt; /dir1/ - redirect
  </code></pre>
  
  <p>and more examples:</p>
  
  <pre><code>/dir1/some-text_index.php/dir2 -&gt; /dir1/some-text_index.php/dir2 - nothing to do
  /dir1/index.php/dir2 -&gt; /dir1/dir2 - redirect
  /dir1/some-text_index.php/dir2/?param=value -&gt; /dir1/some-text_index.php/dir2/?param=value - nothing to do
  /dir1/index.php/dir2/?param=value -&gt; /dir1/dir2/?param=value - redirect
  </code></pre>
  
  <p>Thanks all for yours attention.</p>