title: htaccess 301 redirect: Matching subfolder to array
body: <p>We are looking to redirect some query pages that are dynamically created based on a user search query, to subject pages (only if the query exactly matches a subject that we have in a list. This list contains +1000 subjects.).</p>
  
  <p>Example:</p>
  
  <p>$subjects = array("Marketing", "History", "Management", "Chemistry");</p>
  
  <p><a href="https://example.com/courses/?search=marketing" rel="nofollow noreferrer">https://example.com/courses/?search=marketing</a> should redirect to <a href="https://example.com/courses/subjects/marketing/" rel="nofollow noreferrer">https://example.com/courses/subjects/marketing/</a> given that it exists in our array of subjects.</p>
  
  <p><a href="https://example.com/courses/?search=email+marketing" rel="nofollow noreferrer">https://example.com/courses/?search=email+marketing</a> should not redirect, given that it does not exist in our subjects array.</p>
  
  <p>We are looking to perform these redirects on the server side using the htaccess  file. Any suggestions on how to best execute on this?</p>