title: htaccess filesmatch(htm|html|php) except two specific files?
body: <p>I want to automatically add the <code>X-Robots-Tag</code> header for all php, htm, html pages EXCEPT <code>/index.php</code> and <code>forgot.php</code>.</p>
  
  <p>This would cover all of them:</p>
  
  <pre><code>&lt;FilesMatch "\.(htm|html|php)$"&gt;
      &lt;IfModule mod_headers.c&gt;
                  Header set X-Robots-Tag "noindex, nofollow"
      &lt;/IfModule&gt;
  &lt;/FilesMatch&gt;
  </code></pre>
  
  <p>But how can I exclude <code>/index.php</code> and <code>/forgot.php</code> from that <code>FilesMatch</code> directive?</p>
  
  <p><strong>What I want it to do :</strong></p>
  
  <p>Valid for all .htm, .html, .php files</p>
  
  <p>Exclude for <code>/index.(htm|html|php)</code>, <code>/forgot.(htm|html|php)</code>, but not <code>*/index.php</code> should be valid.</p>
  
  <p>Hopefully that makes sense... I just want to exclude it from those two specific files at the base of the site.</p>
  
  <p><strong>UPDATE:</strong>
  Playing around with this on <a href="https://regex101.com/" rel="nofollow">tester</a>, but still have some issues :</p>
  
  <pre><code>(?!.*/(index.php|forgot))(^.*\.(php|htm|html)$)
  </code></pre>
  
  <p>this is excluding URLs like <code>www.mysite.com/folder/index.php</code></p>